Skip to content

Conversation

@ManifoldFR
Copy link
Member

@ManifoldFR ManifoldFR commented Aug 19, 2025

This PR adds support for MSAA as an antialiasing technique (and so far, the only planned one) to Candlewick.

This was a pain to figure out but we've got it working.

There is full support for MSAA up to 8x (the maximum texture sample count in SDLGPU). The deferred effects (SSAO, transparency) are still supported.

As part of the major changes, we now have HiDPI support, and no longer directly render to the window swapchain (for convenience reasons due to having to manage MSAA workflows in the rendering code).

Comparisons

Before (no MSAA)
cdw_screenshot 2025-08-19 16-59-59 +0200

After (8x MSAA) (observe the grid lines far out and the robot arm's shoulder)
cdw_screenshot 2025-08-19 16-59-50 +0200

Other changes

  • We now always render the opaque (triangle) geometry pass normals to the G-buffer (in R16G16 format. they are used for SSAO). Only the resolved normals are stored, the store op for multisampled G-buffer normals is "Don't care" in the render pass.
  • Change default grid color
  • Python: expose some attributes on Window (wrapper for SDL_Window)
  • Added a GraphicsPipeline RAII wrapper class because I was tired of cleaning up pipeline resources manually. Also significantly cleaned up pipeline management for the RobotScene render system. Several non-ECS/non-Visualizer examples were also updated to show its use.
  • Moved ImGui-related shortcut functions into the new candlewick::gui namespace.
  • Tested HiDPI support, at least on Linux + Wayland as far as I've tested.
  • Fixed the source location in error messages thrown with the terminate_with_message() function. I did a trick using class template automatic deduction (CTAD).
  • Cleaned up unused Config struct members in RobotScene.

Contributed PRs

In the course of making the changes I contributed libsdl-org/SDL#13768 to SDL. Not sure I need it since the final MSAA resolve is done in the order-independent transparency (OIT) composite pass, which has a single render target.

fixup GraphicsPipeline introduction
fixup GraphicsPipeline use in shadow pass
…t introducing MSAA texture buffers

+ RenderContext now hides swapchain, user must access color
  target thru getter
+ make depth texture private, add depthTarget() getter
+ getters for main color/depth targets automatically switch to MSAA
  textures if needed

update all render systems/effects for new RenderContext API
+ make things work on High DPI display
@ManifoldFR ManifoldFR self-assigned this Aug 19, 2025
@ManifoldFR ManifoldFR added this to the Candlewick 1.x milestone Aug 19, 2025
@ManifoldFR ManifoldFR merged commit 975c939 into main Aug 20, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants