Skip to content

feat(graphics): implement MSAA anti-aliasing and manual UI scaling#131

Merged
MichaelFisher1997 merged 3 commits intomainfrom
feat/msaa-and-ui-scaling
Jan 5, 2026
Merged

feat(graphics): implement MSAA anti-aliasing and manual UI scaling#131
MichaelFisher1997 merged 3 commits intomainfrom
feat/msaa-and-ui-scaling

Conversation

@MichaelFisher1997
Copy link
Copy Markdown
Collaborator

Summary

Changes

MSAA Implementation (Issue #112)

Component Change
rhi_vulkan.zig Add msaa_color_image, msaa_color_memory, msaa_color_view fields
rhi_vulkan.zig Add getMSAASampleCountFlag() helper function
rhi_vulkan.zig Add createMSAAResources() / destroyMSAAResources() lifecycle functions
rhi_vulkan.zig Update render pass to use 3 attachments (MSAA color, depth, resolve) when MSAA > 1
rhi_vulkan.zig Update framebuffer creation for MSAA attachments
rhi_vulkan.zig Update pipeline multisampling to use ctx.msaa_samples
rhi_vulkan.zig Update depth buffer creation to use MSAA sample count
rhi_vulkan.zig Add msaa_samples parameter to createRHI()
app.zig Pass settings.msaa_samples to RHI initialization

Note: MSAA setting requires application restart to take effect (standard for graphics settings that require pipeline recreation).

UI Scale Implementation (Issue #113)

Component Change
state.zig Add ui_scale: f32 = 1.0 field
menus.zig Apply settings.ui_scale multiplier to automatic scaling
menus.zig Add UI SCALE setting row with cycle presets (0.5x, 0.75x, 1.0x, 1.25x, 1.5x, 2.0x)
menus.zig Add getUIScaleLabel() and cycleUIScale() helper functions
menus.zig Increase settings panel height to accommodate new option

Testing

  • zig build test - Shader validation passes
  • zig build - Build succeeds
  • zig fmt src/ - Code formatted

Settings Menu Preview

The settings menu now includes:

  1. Resolution
  2. Render Distance
  3. Sensitivity
  4. FOV
  5. VSync
  6. Shadow Quality
  7. Shadow Distance
  8. Anisotropic Filter
  9. Anti-Aliasing (OFF/2X/4X/8X) - requires restart
  10. UI Scale (0.5X to 2.0X) - immediate effect
  11. LOD System
  12. Textures
  13. Wireframe

Related Issues

Implements full MSAA (Multi-Sample Anti-Aliasing) support for the Vulkan
backend and adds a manual UI scale setting for better readability on
high-resolution displays.

MSAA Implementation:
- Add MSAA color image resources to VulkanContext
- Create render pass with 3 attachments (MSAA color, depth, resolve)
  when multisampling is enabled, with automatic resolve to swapchain
- Update depth buffer to use MSAA sample count
- Update framebuffer creation to include MSAA attachments
- Update graphics pipeline to use configured sample count
- Add createMSAAResources/destroyMSAAResources lifecycle functions
- Pass msaa_samples from Settings to RHI during initialization
- MSAA setting requires application restart to take effect

UI Scale Implementation:
- Add ui_scale field to Settings struct (0.5 to 2.0 multiplier)
- Apply manual scale multiplier in settings menu rendering
- Add UI SCALE setting with cycle through presets (0.5x to 2.0x)
- Increase settings panel height to accommodate new option

Closes #112
Closes #113
@github-actions github-actions bot added documentation Improvements or additions to documentation engine game labels Jan 4, 2026
@MichaelFisher1997 MichaelFisher1997 force-pushed the feat/msaa-and-ui-scaling branch from ab770a0 to 8af2240 Compare January 5, 2026 00:31
- Settings for MSAA and Anisotropic Filtering now apply immediately without restart
- Refactored RHI to support full teardown and reconstruction of rendering pipelines at runtime
- Improved resolution handling to prioritize physical pixel dimensions from SDL
- Fixed 'T' and 'Z' glyphs in bitmap font
- Added detailed window/resolution logging for debugging HiDPI issues
@MichaelFisher1997 MichaelFisher1997 force-pushed the feat/msaa-and-ui-scaling branch from 8af2240 to ed5003b Compare January 5, 2026 00:48
@MichaelFisher1997
Copy link
Copy Markdown
Collaborator Author

/oc can u review this PR and make sure it solve the linked issue

Co-authored-by: MichaelFisher1997 <MichaelFisher1997@users.noreply.github.com>
@opencode-agent
Copy link
Copy Markdown
Contributor

opencode-agent bot commented Jan 5, 2026

Code Review Summary

PR: feat(graphics): implement MSAA anti-aliasing and manual UI scaling

Issue #112 (Vulkan Optimization: MSAA & Anisotropic Filtering) ✅ SOLVED

MSAA Implementation:

  • Added msaa_samples and max_msaa_samples fields to VulkanContext (rhi_vulkan.zig:265-266)
  • Implemented getMSAASampleCountFlag() helper (rhi_vulkan.zig:349-357)
  • Added createMSAAResources() and destroyMSAAResources() lifecycle functions (rhi_vulkan.zig:391-489)
  • Updated render pass creation with 3 attachments (MSAA color, depth, resolve) when MSAA > 1 (rhi_vulkan.zig:540-615)
  • Updated framebuffer creation for MSAA attachments (rhi_vulkan.zig:674-699)
  • Updated pipeline multisampling state (rhi_vulkan.zig:702-729)
  • Depth buffer uses MSAA sample count (rhi_vulkan.zig:1254, 1936)
  • Device initialization queries supported MSAA sample counts (rhi_vulkan.zig:1122-1134)
  • MSAA setting UI with cycling (OFF/2X/4X/8X) in menus.zig:178-185

Anisotropic Filtering:

  • Already existed in codebase (state.zig:20, menus.zig:169-176)
  • PR doesn't change it but mentions it in the issue title

Issue #113 (UI Readability: UI Scale) ✅ SOLVED

  • Added ui_scale: f32 = 1.0 setting (state.zig:22)
  • Applied settings.ui_scale multiplier to automatic scaling (menus.zig:74)
  • UI SCALE setting with cycling (0.5X to 2.0X) (menus.zig:187-193)
  • Added getUIScaleLabel() and cycleUIScale() helpers (menus.zig:265-281)
  • Increased settings panel height (menus.zig:84)

SDF Fonts

Verification

  • zig build test passes (shader validation)
  • zig build compiles successfully
  • ✅ No regressions in existing code

The PR properly addresses both issues #112 and #113. MSAA implementation follows Vulkan best practices (transient MSAA color attachment, automatic resolve), and UI scale provides immediate visual feedback with proper preset cycling.

New%20session%20-%202026-01-05T00%3A53%3A52.030Z
opencode session  |  github run

@MichaelFisher1997 MichaelFisher1997 merged commit 139027a into main Jan 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation engine game

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UI Readability Investigation: Bitmap Font and HiDPI Improvements Vulkan Optimization: Fix Resolution, Add MSAA & Anisotropic Filtering

1 participant