Commit Graph

34 Commits

Author SHA1 Message Date
Sam Lantinga 2aee105b43 Added support for custom shaders with the GPU renderer
Added an example of MSDF font rendering with the SDL 2D renderer
2025-03-14 09:26:30 -07:00
Sam Lantinga 1ae4ef65e6 Fixed incorrect assert 2025-03-13 22:37:08 -07:00
Sam Lantinga 3e9e22f17d Added SDL_SCALEMODE_PIXELART
This is based on the algorithm presented by t3ssel8r:
https://www.youtube.com/watch?v=d6tp43wZqps
2025-03-13 09:48:37 -07:00
Sam Lantinga 853375da61 Removed texture_size from the GPU renderer vertex shader
This isn't used anywhere, and this saves a UV multiply and divide
2025-03-13 09:48:37 -07:00
Sam Lantinga 28ec461ebf Organize the GPU renderer draw code 2025-03-13 09:48:37 -07:00
Sam Lantinga af0420d898 Switched GPU renderer shaders to shadercross and HLSL 2025-03-13 09:48:37 -07:00
Sam Lantinga cb099ebd4f Make texture scale mode a part of the 2D renderer draw state
Also added texture addressing mode support to the PSP and Vita renderers (untested)

Fixes https://github.com/libsdl-org/SDL/issues/12461
2025-03-05 21:35:04 -08:00
Ryan C. Gordon 84a236c92e hashtable: Redesign the hashtable API.
This was intended to make the API public, so SDL_hashtable.h got an extreme
documentation makeover, but for now this remains a private header.

This makes several significant interface changes to SDL_HashTable, and
improves code that makes use of it in various ways.

- The ability to make "stackable" tables is removed. Apparently this still
  worked with the current implementation, but I could see a future
  implementation struggle mightily to support this. It'll be better for
  something external to build on top of the table if it needs it, inserting a
  linked list of stacked items as the hash values and managing them separately.
  There was only one place in SDL using this, unnecessarily, and that has also
  been cleaned up to not need it.
- You no longer specify "buckets" when creating a table, but rather an
  estimated number of items the table is meant to hold. The bucket count was
  crucial to our classic hashtable implementation, but meant less once we
  moved to an Open Addressing implementation anyhow, since the bucket count
  isn't static (and they aren't really "buckets" anymore either). Now you
  can just report how many items you think the hash will hold and SDL will
  allocate a reasonable default for you...or 0 to not guess, and SDL will
  start small and grow as necessary, which is often the correct thing to do.
- There's no more SDL_IterateHashTableKey because there's no more "stackable"
  hash tables.
- SDL_IterateHashTable() now uses a callback, which matches other parts of SDL,
  and also lets us hold the read-lock for the entire iteration and get rid of
  the goofy iterator state variable.
- SDL_InsertIntoHashTable() now lets you specify whether to replace existing
  keys or fail if the key already exists.
- Callbacks now use SDL conventions (userdata as the first param).
- Other naming convention fixes.

I discovered we use a lot of hash tables in SDL3 internally. :) So the bulk
of this work is fixing up that code to use the new interfaces, and simplifying
things (like checking for an item to remove it if it already exists before
inserting a replacement...just do the insert atomically, it'll do all that
for you!).
2025-02-15 18:52:56 -05:00
Sam Lantinga 3cfa476d3f Added support for SDL_PIXELFORMAT_ABGR8888 textures
This is the output format of stb_image for image decoding, so let's avoid a texture format conversion where possible.

Also standardized SDL_PIXELFORMAT_ARGB8888 as the default texture format for all renderers.
2025-02-10 19:45:02 -08:00
Sam Lantinga 7c6adc1ca7 gpu renderer: removed unused sampler slots
There used to be 3 scale modes, now there are only 2.
2025-01-17 16:31:40 -08:00
Sam Lantinga f2074d7af3 Updated copyright for 2025 2025-01-01 07:45:52 -08:00
Lucas Murray cc24518c41 render: Update GPU backend to use the new present workflow 2024-12-27 17:11:55 -08:00
Sam Lantinga 969f03d9f0 Added SDL_PROP_RENDERER_GPU_DEVICE_POINTER
Fixes https://github.com/libsdl-org/SDL/issues/11600
2024-12-23 16:51:43 -08:00
Sam Lantinga 61511c48a4 SDL_HashTable is now optionally thread-safe
Fixes https://github.com/libsdl-org/SDL/issues/11635
2024-12-12 14:39:53 -08:00
Evan Hemsley 119b4fa5f5
GPU: Remove D3D11 backend and allow D3D12 to ingest DXBC (#11456) 2024-11-12 10:55:21 -08:00
Sam Lantinga 87dade4421 Set SDL_PROP_RENDERER_MAX_TEXTURE_SIZE_NUMBER for the GPU renderer
Fixes https://github.com/libsdl-org/SDL/issues/11393
2024-11-01 18:38:42 -07:00
Sam Lantinga e2254b1045 Added color scale info for the GPU renderer TODO item 2024-10-20 18:38:02 -07:00
Sam Lantinga 97f1da73da Rename GPU properties for consistency 2024-10-15 15:36:26 -07:00
Sam Lantinga 3234a3b902 Simplified internal SDL_Surface structure 2024-10-01 08:10:04 -07:00
cosmonaut 3eab599977 just force the barrier on UpdateTexture actually 2024-09-30 19:47:27 -07:00
cosmonaut e17741a6cb Render GPU: Only cycle on update if entire texture is replaced 2024-09-30 19:47:27 -07:00
Sam Lantinga 45ad763de5 Disable backface culling and use a constant rectangle winding order.
This makes it so we don't have to surface the rectangle winding order for applications that want to use the raw geometry API.
2024-09-30 19:12:02 -07:00
Evan Hemsley afdf325fb4
GPU: Add swapchain dimension out params (#11003) 2024-09-30 10:23:19 -07:00
Sam Lantinga 0e45b824e3 renderer: always update the output pixel size at startup
Fixes https://github.com/libsdl-org/SDL/issues/10990
2024-09-29 05:22:28 -07:00
Evan Hemsley 66f6b40c92
Render GPU: Don't call GetWindowSizeInPixels during RenderPreset (#10984) 2024-09-28 18:01:16 -07:00
Evan Hemsley be401dd1e3
GPU: More robust error reporting (#10958)
---------

Co-authored-by: Ethan Lee <flibitijibibo@gmail.com>
Co-authored-by: Caleb Cornett <caleb.cornett@outlook.com>
2024-09-27 00:30:18 -07:00
Ryan C. Gordon bf7a48cdcc render/gpu: Change some memcpy calls to SDL_memcpy. 2024-09-25 16:26:36 -04:00
Simon McVittie 23f855a970 render: Integrate fix-shaders.sh into build-shaders.sh
By writing the fxc and dxc output to a temporary file and then
converting that temporary file to the desired filename, we avoid
the incompatible semantics of sed -i on GNU systems (sed -i does not
create a backup filename, and does not take an argument unless it is
"bundled") and macOS (sed -i requires an argument, possibly empty).

Resolves: https://github.com/libsdl-org/SDL/issues/10878
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-18 10:38:59 -07:00
Sam Lantinga a90ad3b0e2 Removed SDL_bool in favor of plain bool
We require stdbool.h in the build environment, so we might as well use the plain bool type.

If your environment doesn't have stdbool.h, this simple replacement will suffice:
typedef signed char bool;
2024-09-18 08:32:30 -07:00
Simon McVittie 4b3058d58d render: Don't try to rebuild D3D11, D3D12, Metal shaders without spirv-cross
Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-17 07:43:37 -07:00
Simon McVittie 13500bbf50 render: Fix detection of fxc, dxc in build-shaders.sh
We want `$USE_FXC` to default to the result of evaluating the variable
`$HAVE_FXC`, not the literal string `HAVE_FXC`, and the same for dxc.

Signed-off-by: Simon McVittie <smcv@debian.org>
2024-09-17 07:43:37 -07:00
Ethan Lee 96e147b2b9 gpu: Rework driver name queries, add GetGPUShaderFormats 2024-09-13 12:29:40 -04:00
Caleb Cornett a45a2caf49
GPU: Rename VertexBinding to VertexBufferDescription (#10811) 2024-09-12 18:02:39 -05:00
Sam Lantinga 4123023d3e Renamed sdlgpu to gpu 2024-09-11 08:34:51 -07:00