Commit Graph

1479 Commits

Author SHA1 Message Date
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
Sam Lantinga
9f9be1425d Fixed permissions 2025-10-06 17:24:56 -07:00
Sam Lantinga
b92557c0b7 Made error message consistent between SDL_SetSurfacePalette() and SDL_SetTexturePalette() 2025-10-06 09:22:34 -07:00
Cameron Cawley
ab06784318 Check the availability of GL_BGRA before use 2025-10-06 08:58:45 -07:00
Cameron Cawley
12cee1cf46 Use the correct pixel formats for OpenGL on big endian 2025-10-06 08:58:45 -07:00
Sam Lantinga
941b0a8ea4 Added support for external GPU textures to the GPU renderer 2025-10-06 07:31:00 -07:00
definability
4d9295ef1e Fixed building with SDL_LEAN_AND_MEAN
Fixes https://github.com/libsdl-org/SDL/issues/14151
2025-10-05 17:36:11 -07:00
Sam Lantinga
134b47730b Added support for linear and pixel art scaling for palettized textures 2025-10-04 15:12:08 -07:00
Sam Lantinga
f3815ede24 Rebuilt GPU renderer shaders 2025-10-03 19:35:45 -07:00
Sam Lantinga
49d51a0d3c Removed TEXTURETYPE_PALETTE_PIXELART
This doesn't make any sense since the pixel art algorithm uses a box filter to get an average pixel value which isn't possible with indexed textures.
2025-10-03 18:54:07 -07:00
Sam Lantinga
ac2c834021 Fixed build 2025-10-03 16:04:45 -07:00
Sam Lantinga
1cda789a37 render: Default to primary display in SDL_CalculateSimulatedVSyncInterval if window is not set
- Fixes previous change to SDL_CreateRendererWithProperties which skipped SDL_CalculateSimulatedVSyncInterval if window was not set.
2025-10-03 16:00:44 -07:00
Sam Lantinga
0cab3521f1 render: Fix asserts from null window usage in SDL_CreateRendererWithProperties 2025-10-03 16:00:41 -07:00
Sam Lantinga
32668c4ddd Palettized textures will always use SDL_SCALEMODE_NEAREST.
Our algorithm for pixel art doesn't work on 8-bit images, needs further investigation.

Fixes https://github.com/libsdl-org/SDL/issues/14129
2025-10-03 14:29:47 -07:00
Sam Lantinga
d333044462 Fixed destination coordinates when using scale with the software renderer
Fixes https://github.com/libsdl-org/SDL/issues/14051
2025-10-03 13:58:45 -07:00
Sam Lantinga
a864dcac25 Added support for using the GPU renderer as an offscreen renderer
SDL_CreateGPURenderer() now allows passing in an existing GPU device and passing in a NULL window to create an offscreen renderer.

Also renamed SDL_SetRenderGPUState() to SDL_SetGPURenderState().
2025-10-01 23:32:18 -07:00
Sam Lantinga
8d7cd3c6c2 Fixed line endings 2025-10-01 14:01:59 -07:00
Sam Lantinga
9735c45db6 Added an advanced shader for the GPU renderer
This allows us to support YUV colorspaces and HDR in the GPU renderer.

Fixes https://github.com/libsdl-org/SDL/issues/11281
Fixes https://github.com/libsdl-org/SDL/issues/11282
2025-10-01 07:17:55 -07:00
Sam Lantinga
fe3b399b7e Added support for P010 pixel format in SDL_UpdateNVTexture() 2025-10-01 07:17:55 -07:00
Sam Lantinga
548063e578 Fixed pixel shader for palettized textures using pixelart scaling 2025-10-01 07:17:55 -07:00
Wohlstand
e3d65796f4 SDL_render_psp.c: Implemented working viewport support
Backported from the SDL2 branch
2025-09-29 19:09:26 -07:00
Sam Lantinga
f61e271e11 Generalize and validate optional GPU feature properties
Fixes https://github.com/libsdl-org/SDL/issues/13139
Fixes https://github.com/libsdl-org/SDL/issues/13138
2025-09-29 12:42:47 -07:00
Sam Lantinga
595f7b7ed9 Revert "Fixed Vulkan validation error"
This reverts commit b82b1f416f.

The renderer should not be enabling depth clamping.
2025-09-29 06:08:27 -07:00
Sam Lantinga
b65590159b Each application palette corresponds to one hardware palette
When the application modifies the palette, any textures that use it will automatically be updated.
2025-09-28 22:10:06 -07:00
Sam Lantinga
5d311635cf Added Vulkan support for palettized textures 2025-09-28 22:10:06 -07:00
Sam Lantinga
e2fe23ddab Added hardware accelerated support for palettized textures
Supported backends: direct3d, direct3d11, direct3d12, gpu, metal, opengl, opengles2
2025-09-28 22:10:06 -07:00
Sam Lantinga
524ba0a4ad Reduce the size of the D3D12 vertex shader constants
This is needed to add more fragment shader constants in the future as we're already at our 64 size limit
2025-09-28 22:10:06 -07:00
Sam Lantinga
5622eef5a8 Fixed memory leak if requested renderer isn't available 2025-09-28 22:10:06 -07:00
Sam Lantinga
2a01e12d34 Simplify palette code
Each texture gets its own palette, the palette is updated when it is rendered if necessary, rendering is flushed if a texture render is already queued up.

Trying to share palettes and handle the different cases of queued rendering and changing palettes in the middle of the frame ends up being very complicated, so we'll keep it simple for now.
2025-09-28 22:10:06 -07:00
Sam Lantinga
7dcc09986d Test changing the palette for a single texture 2025-09-28 22:10:06 -07:00
Sam Lantinga
264b436dba Fixed changing palettes while rendering is in flight 2025-09-28 22:10:06 -07:00