Skip to content

Conversation

@Bigfoot71
Copy link
Contributor

I further simplified the framebuffer management logic, mainly by unifying the color and depth buffers.

I also added a fast path for blit/copy operations where a blit with identical dst/src dimensions now falls back to a simple copy, and a copy with the same dimensions and format (RGBA32/RGB16) as the framebuffer performs a simple linear copy.

glClearDepth() and GL_DEPTH_CLEAR_VALUE (getter) have also been added.

There was also a fix in the framebuffer copy, if the dimensions weren't exact, the pointer was being incorrectly incremented.

I also revisited the SIMD functions for float <=> unorm8 color conversion, they now avoid explicit clamp (min/max) operations.


Regarding the unified buffer, it has both advantages and drawbacks...

The main drawback is that it's an AoS, which is suboptimal (or even incompatible) if we ever move to fully manual SIMD rasterization.
However, reverting to separate buffers at that point would be trivial compared to the rest of the work.

The advantages are a cleaner and more natural logic, a bit less pointer arithmetic, and logically fewer cache misses during rasterization.

Initially, after unifying the buffers, I saw no visible performance difference on my side with -O3, which is good considering the code simplification.

With the subsequent changes, I noticed a slight performance increase on the bunnymark test.

@Bigfoot71
Copy link
Contributor Author

Bigfoot71 commented Oct 28, 2025

Oh and the first commit adds the SW_ prefix to some macros and definitions...
I'll try to do smaller specific PRs next time for this kind of thing

my french slipped out
@raysan5 raysan5 merged commit f4ed8fc into raysan5:master Oct 28, 2025
16 checks passed
@raysan5
Copy link
Owner

raysan5 commented Oct 28, 2025

@Bigfoot71 Nice! Thanks for the improvement! 🚀

@raysan5
Copy link
Owner

raysan5 commented Oct 28, 2025

@Bigfoot71 It seems this PR breaks compilation on Visual Studio...

image

raysan5 added a commit that referenced this pull request Oct 28, 2025
…5312

Added a workaround but it has other probably undesired implications
@raysan5
Copy link
Owner

raysan5 commented Oct 28, 2025

Reviewed the issue but not sure if that's the best approach, is it possible to just avoid alignas()?

@raysan5
Copy link
Owner

raysan5 commented Oct 28, 2025

@Bigfoot71 Found another issue when trying to build for PLATFORM_DRM, swGetColorBuffer() has been removed and was required by the platform...

raysan5 added a commit that referenced this pull request Oct 28, 2025
`PLATFORM_DRM` depends on it but if there is a better approach to get the buffer, it can just be removed again and replaced by alternative.
@Bigfoot71
Copy link
Contributor Author

Found another issue when trying to build for PLATFORM_DRM, swGetColorBuffer() has been removed and was required by the platform...

I was going to make another PR, but I'll take care of this first, I'll fix this problem for DRM

@Bigfoot71
Copy link
Contributor Author

Reviewed the issue but not sure if that's the best approach, is it possible to just avoid alignas()?

We could, but it's still preferable, I'll review that too, I forgot it was C11 :/
It required a review anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants