Commit Graph

484 Commits

Author SHA1 Message Date
Ray
0d78f10161 Reviewed comments formating 2026-05-20 09:16:16 +02:00
Colin James Wood
7d5b61ce01 [rlsw][SEGFAULT] Fix triangle and quad spans applying pixels out of bounds (#5849)
* fix triangle and quad spans applying pixels out of bounds

* remove off by one errors on x/y LoopMax

* apply the RASTER_QUAD offset at the loop start so it increments correctly

* fix missing endif

* remove include guard to allow dyMin usage

* early exit if nothing to draw on a span

* incorporate dxStart into xSubstep to make xOffset calculate a single time

* remove ghost comment

* early exit for quads, with a float cast on the left and top distance calculation

* remove duplicate xLoopEnd
2026-05-20 09:12:20 +02:00
Ray
fd1dfd7d65 ADDED: rprand_get_value_raw() 2026-05-19 18:59:23 +02:00
Ray
43366d1c6a Some formatting tweaks 2026-05-13 09:28:08 +02:00
Ray
5aa3de194c Updated miniaudio warnings with emscripten 2026-05-12 20:33:20 +02:00
Faraz Fallahi
07b729d5d6 fix: check fread return value in jar_mod_load_file (#5840) 2026-05-09 18:55:02 +02:00
Ray
b2ea5eae5e REVIEWED: long long usage in all raylib, minimize
REVIEWED: Using `long long` format instead of `long long int`, more consistent with the `short` alternative for smaller `int`, instead of `short int`
2026-05-08 22:59:55 +02:00
Ray
33e889907e ADDED: GL_SHADING_LANGUAGE_VERSION for swGetString() 2026-05-07 15:20:24 +02:00
Colin James Wood
080f5c94bd [rlsw][rcore_drm] Silence warnings when using PLATFORM_DRM and GRAPHICS_API_OPENGL_SOFTWARE (#5839)
* fix warnings: goto label not used outside of SW_ENABLE_DEPTH_TEST

* comment out x coordinates that aren't used in SW_RASTER_TRIANGLE

* silence warnings: unused DrmModeConnector functions in rcore_drm.c when using GRAPHICS_API_OPENGL_SOFTWARE
2026-05-07 15:17:20 +02:00
Jens Roth
7207c03c72 [rlsw] ESP32 optimizations (#5827)
* [rlsw] Add sw_rcp helper using Xtensa recip0.s for hot-path divisions

Adds a `sw_rcp(x)` inline reciprocal that on Xtensa (ESP32 / ESP32-S3
LX6/LX7) emits a `recip0.s` seed plus two Newton-Raphson refinement
steps -- 1-ULP accurate in ~7 instructions, all in FPU registers.
On every other target it expands to plain `1.0f/x`, so generated code
is byte-identical to before for non-Xtensa builds.

Replaces the hot-path `1.0f/x` calls that were previously compiling to
the `__divsf3` software helper on Xtensa:

  - perspective divide (1/w) in triangle clip-and-project (PCT and PC paths)
  - line and point clip-and-project NDC conversion
  - triangle span setup: dxRcp, blockLenRcp, wRcpA, wRcpB
  - triangle scanline setup: h02Rcp, h01Rcp, h12Rcp
  - axis-aligned quad: wRcp, hRcp
  - line rasterizer: stepRcp

Other `1.0f/x` uses (matrix translate/normalize, texture init `tx`/`ty`,
sw_matrix_rotate inverse-length) are not on the per-pixel hot path and
are left untouched.

Measured on ESP32-S3 @ 240 MHz, R5G6B5 240x240, textured 3D model:
contributes to a ~10-15% rasterization speedup.

Made-with: Cursor

* [rlsw] Use ESP-DSP for 4x4 matrix multiply and per-vertex MVP transform

Adds an opt-in ESP-DSP code path for ESP32 / ESP32-S3 builds. ESP-DSP is
ESP-IDF's official optimized math library and ships hand-vectorized
kernels that beat the scalar implementations on Xtensa.

Two integration points:

  1. `sw_matrix_mul_rst` -> `dspm_mult_4x4x4_f32` for any 4x4*4x4 multiply
     (used for MVP build, gluLookAt, push/multiply, etc.). rlsw stores
     matrices column-major and ESP-DSP reads row-major; the comment on the
     call site explains why the flat-buffer call still produces the
     correct column-major product (transpose-of-transposes equivalence).

  2. `sw_immediate_push_vertex` -> `dspm_mult_4x4x1_f32` for the per-vertex
     clip-space transform. Because ESP-DSP expects a row-major matrix in
     this case, a row-major copy `matMVP_rm[16]` is maintained alongside
     `matMVP` and refreshed once per `isDirtyMVP` rebuild in
     `sw_immediate_begin`. Cost is 16 scalar copies per matrix update,
     amortized over thousands of vertices per frame.

Detection is **opt-in** via `SW_USE_ESP_DSP` so existing ESP-IDF projects
that don't depend on the `esp-dsp` component keep building unchanged.
A user enables it from CMakeLists.txt (or anywhere before including
rlgl.h):

    target_compile_definitions(${COMPONENT_LIB} PRIVATE SW_USE_ESP_DSP=1)

and adds the dependency to `idf_component.yml`:

    espressif/esp-dsp: "^1.4.0"

Measured on ESP32-S3 @ 240 MHz, R5G6B5 240x240, textured 3D model:
contributes meaningfully to the overall frame-time improvement
(combined with sw_rcp).

Made-with: Cursor

* [rlsw] Add SW_TEXTURE_REPEAT_POT_FAST opt-in for POT bitmask wrap

Adds an opt-in compile-time flag that replaces the SW_REPEAT wrap chain
with a bitmask (`x & (size-1)`) for power-of-two textures. NPOT textures
keep using the original `sw_fract` / signed-modulo paths via a runtime
`(size & (size-1)) == 0` check, so SW_REPEAT remains correct for them.

Affects two samplers:

  - `sw_texture_sample_nearest`: drops the `floorf` + multiply + cast for
    POT textures in REPEAT mode (saves a software call on Xtensa).
  - `sw_texture_sample_linear`: replaces the `(x % w + w) % w` two-step
    modulo (a software divide on Xtensa) with a single bitwise AND for
    POT textures in REPEAT mode. Two's-complement int wrap covers
    negative coordinates correctly.

Off by default: for POT textures sampled with negative UVs, bitmask wrap
can differ from `sw_fract` wrap by one texel at the boundary. That is
imperceptible at typical resolutions but technically a behavior change,
so existing users get bit-for-bit identical output. Opt in if you
control your asset UVs and want the speedup:

    #define SW_TEXTURE_REPEAT_POT_FAST

This addresses the long-standing TODO comment "If the textures are POT,
avoid the division for SW_REPEAT" in `sw_texture_sample_linear`.

Made-with: Cursor
2026-05-06 12:38:52 +02:00
Ray
06621eb3b7 REVIEWED: Comments for consistency and spelling 2026-04-27 11:34:58 +02:00
Jeffery Myers
8e82249f65 Update to latest DR libs to fix some warnings in MSVC (#5808) 2026-04-26 20:16:35 +02:00
Ray
a5427bc38f Update rlsw.h 2026-04-12 11:07:09 +02:00
Ray
1122add3ee Minor format tweak 2026-04-04 17:36:18 +02:00
Ray
6c0134bb5c Create cgltf_write.h 2026-03-29 21:24:24 +02:00
Ray
e9231bc4f1 Update stb_image_resize2.h 2026-03-29 21:24:20 +02:00
Ray
4c79c6837b Update qoi.h 2026-03-29 21:21:16 +02:00
Ray
e5f0c9f8b1 Update qoa.h 2026-03-29 21:21:11 +02:00
Ray
d5326fe880 Update m3d.h 2026-03-29 21:20:23 +02:00
Ray
adc4c9b875 Update dr_wav.h 2026-03-29 21:19:31 +02:00
Ray
b09da8fce8 Update dr_mp3.h 2026-03-29 21:18:56 +02:00
Ray
0b87a35e5a Update dr_flac.h 2026-03-29 21:18:28 +02:00
Ray
a1bf8d9c75 Update cgltf.h 2026-03-29 21:17:51 +02:00
Ray
0f0983c065 Remove trailing spaces 2026-03-25 16:51:02 +01:00
Le Juez Victor
8a685877eb [rlsw] Remove position attribute from sw_vertex_t (#5677)
* review `sw_vertex_t`

* fix comment

* fix pop matrix
2026-03-20 12:07:50 +01:00
Ray
8783e66e21 Update rlsw.h 2026-03-19 23:42:20 +01:00
Le Juez Victor
7ae46fb2e6 [rlsw] Micro-optimizations, tighter pipeline and cleanup (#5673)
* auto generates all combinations of blending factors
This adds a macro system that generate a function for each possible combination of blending factors, resulting in 11*11 functions, hence 121.
This then allows for only one indirection and function call instead of two previously (assuming the first call was inlined).

* rename dispatch tables for consistency

* change blend funcs validity check
Simplifies the validation of blend functions.
Can allow `SW_SRC_ALPHA_SATURATE` as dst factor, but hey

* disables blending when it requires alpha and there is none

* review immediate rendering functions and attribute layout

* prevent state changes during immediate record

* reduce number of op for each vertex push + review primitive struct

* simplified draw functions

* review `sw_vertex_t`
removes `float screen[2]`; each step stores the transformed coordinates in `float coord[4]`.
This also simplifies vertex interpolation during triangle rasterization.

* reduces unnecessary interpolation costs during triangle rasterization + cleanup

* extends the simd color conversion to more cases

* affine interpolation per blocks

* long side check for each triangle line
My mistake in a previous commit

* style tweaks

* select the read function on texture load
This removes the per-pixel switch; it's slightly more efficient on my hardware, but probably a poor prediction
Should remain profitable or at worst the same

* use optionnal LUT for uint8_t -> float conversion

* sets internal the number of vertices post-clipping and the epsilon clipping + a little cleanup

* moves color conversion to math part

* prevents sampling if it's a depth texture that is bound
2026-03-19 23:39:52 +01:00
Ray
04c5dc4493 REVIEWED: PR #5674 2026-03-19 23:35:18 +01:00
Juraj Michálek
bca4f83a02 required change for ESP-IDF 6 (#5674) 2026-03-19 23:19:44 +01:00
Ray
2a3b28b67a Reviewed some comments 2026-03-18 16:21:35 +01:00
Ray
85df4e7de5 REVIEWED: rlsw, use provided library information 2026-03-18 13:31:09 +01:00
Ray
2c39703d13 RENAMED: rl_gputex to rltexgpu 2026-03-18 13:28:45 +01:00
Le Juez Victor
d657e86043 [rlsw] Fix typos, update build scripts, and align style (#5669)
* fix typo that appeared during re-format

* fix build scripts for `GRAPHICS_API_OPENGL_SOFTWARE`

* consistency tweak
2026-03-17 20:01:45 +01:00
Ray
48a34d63ed Update rlsw.h 2026-03-17 18:35:33 +01:00
Ray
6ddf9a1885 Code review, format tweaks, defined version to 1.5 2026-03-17 18:30:48 +01:00
Le Juez Victor
e7d999e3c7 [rlsw] RenderTexture support (#5655)
* review texture formats
Added support for `R3G3B2`, `R5G6B5`, `R4G4B4A4` and `R5G5B5A1`
Added depth formats

* use of textures for the framebuffer
- Framebuffers can now use all texture types that are already available.
- The 24-bit depth format has been removed as it is no longer needed.
- Framebuffer formats are still defined at compile time.
- The allocated texture size is now preserved, which avoids frequent reallocations when resizing framebuffers and will allow the use of `glTexSubImage2D`.

* review framebuffer blit/copy
This greatly simplifies the framebuffer blit/copy logic while now supporting all pixel formats. It is slightly slower in debug builds, but this path is mainly kept for compatibility anyway. The `copy_fast` version is still used for the "normal" cases when presenting to the screen.

* review pixel get/set
less ops for certain formats + fixes

* fix depth write

* texture read/write cleanup + tweaks
I made the  pointers parameters `restrict` for reading/writing textures, which resulted in a slight improvement.
And I reviewed the `static inline` statements, which could potentially bias the compiler; no difference, but it's cleaner.

* style tweaks

* review uint8_t <-> float conversion

* added a reusable object pool system
will allow management of both textures and framebuffers
added support for `glTexSubImage2D`
added handling of 'GL_OUT_OF_MEMORY' errors
removed the default internal texture (unused)

* added FBO API + refactored rasterizer dispatch logic

* fix ndc projection + review presentation
and rename rlsw's resize/copy/blit

* add `glRenderbufferStorage` binding
+ tweaks and fixes

* fix quad sorting + simplify quad rasterization part

* fix line shaking issue

* support of `GL_DRAW_FRAMEBUFFER_BINDING`

* update rlgl - support of rlsw's framebuffers

* fix pixel origin in line rasterization
my bad, an oversight in my previous fix.
This offset should have been moved here rather than per pixel during truncation.

* style tweaks

* fix vla issue with msvc - fill depth / fill color
2026-03-17 17:50:32 +01:00
Maicon Santana
2eaac95df0 Check if locs is not null before try to access (#5622) 2026-03-04 19:16:22 +01:00
Ray
faf42366ec Code gardening 2026-03-04 01:14:26 +01:00
Ray
b4746469d4 Formating review, using imperative mode in comments 2026-03-03 22:40:34 +01:00
Ray
5361265a7d WARNING: BREAKING: REDESIGNED: raylib build features config system #4411 #4554
Redesigned to support disabling features on compilation with `-DSUPPORT_FEATURE=0`
REMOVED: `SUPPORT_DEFAULT_FONT`, always supported
REMOVED: `SUPPORT_IMAGE_MANIPULATION `, always supported
REMOVED: `SUPPORT_TEXT_MANIPULATION`, always supported
REDESIGNED: `SUPPORT_FONT_ATLAS_WHITE_REC` to `FONT_ATLAS_CORNER_REC_SIZE`
REVIEWED: Config values (other than 0-1) are already defined on respective modules
Other config tweaks here and there
2026-02-26 08:19:28 +01:00
Thomas Anderson
b57526d71e update makefile and such (#5591) 2026-02-26 00:38:37 +01:00
Krzysztof Szenk
4ebe7d6215 win32 clipboard: fix for BI_ALPHABITFIELDS narrow support (#5586)
* win32 clipbaord: fix for BI_ALPHABITFIELDS narrow support

* Define BI_ALPHABITFIELDS even if wingdi headers are already included

since BI_ALPHABITFIELDS is not always defined there
2026-02-24 12:56:16 +01:00
Thomas Anderson
fbd83cafc7 [Backend/RGFW] Update RGFW to 2.0.0 (#5582)
* initial update

* minor changes

* added minigamepad

* updates

* updates - 2.0-dev

* update char press

* update gamepad

* update gamepad

* update (web)

* update rename, spacing, etc

* updates

* updates for mac-arm64

* moved RGFW into folder

* highdpi fixes

* update windowPos (bug remaining somewhere)

* temp stash, macos fixes for pixelratio

* highdpi resize window fixes

* remove unneeded makefiles

* fix undef oopsie

* update fullscreen/borderless

* update macos defines for older macs and newer ones

* update resizing window
2026-02-22 22:21:09 +01:00
Ray
8e81ca0e60 Update win32_clipboard.h 2026-02-12 19:08:48 +01:00
Ray
efda35b309 Update win32_clipboard.h 2026-02-10 00:37:45 +01:00
Ray
b39cc6bce7 Update win32_clipboard.h 2026-02-09 23:28:02 +01:00
Ray
7e59e1d93d REVIEWED: Formating 2026-02-09 22:29:47 +01:00
Viktor Demčák
eda915232d Update miniaudio to v0.11.24 (#5506) 2026-01-23 14:13:17 +01:00
Ray
29896a2403 REVIEWED: Some comments (Code Gardening) 2026-01-19 12:40:32 +01:00
Krzysztof Szenk
0bcf79ce28 [#5455] Fix for: Fix window width calculation by adding wOffset (#5480) 2026-01-08 17:26:56 +01:00