Skip to content

RealAdarsh/wgpu-drm-renderer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WGPU DRM Renderer

A high-performance GPU renderer that directly outputs to DRM framebuffer for maximum efficiency. This project demonstrates optimized rendering from GPU to display using wgpu and Linux DRM APIs with double-buffering and hardware page flipping.

Features

  • Direct GPU to DRM framebuffer rendering
  • Double-buffered presentation with hardware page flipping
  • High-performance optimized rendering pipeline
  • Real-time FPS monitoring with instantaneous and average metrics
  • Frame time analysis with min/max tracking
  • Zero-copy memory operations where possible
  • Vulkan backend for maximum performance
  • Clean, production-ready codebase

Requirements

  • Linux system with DRM support
  • Vulkan-capable GPU and drivers
  • Root access or proper DRM device permissions
  • Rust 1.70+ with Cargo

Quick Start

  1. Build the project:

    ./build.sh

    Or manually:

    cargo build --release
  2. Check DRM permissions:

    ./check_permissions.sh
  3. Run the renderer:

    sudo ./target/release/wgpu-drm

Performance Monitoring

The renderer provides detailed performance metrics:

Frame 120: Instant FPS: 142.7, Average FPS: 145.2, Frame time: 7.01ms (min: 6.89ms, max: 8.45ms)
  • Instant FPS: Real-time performance based on recent frame times
  • Average FPS: Overall performance since startup
  • Frame Time: Current frame rendering duration
  • Min/Max: Performance variance analysis

Performance

The renderer typically achieves high frame rates on modern hardware, with performance depending on GPU capabilities and display resolution. The optimized pipeline runs without artificial frame rate limiting for maximum throughput.

Architecture

  • main.rs - Clean entry point with production-ready initialization
  • drm_surface.rs - DRM device management, buffer allocation, and page flipping
  • renderer.rs - WGPU rendering pipeline with advanced FPS tracking
  • texture.rs - Texture loading utilities
  • shaders.wgsl - Vertex and fragment shaders

Technical Details

The renderer implements:

  • Double-buffered DRM surface with mapped memory
  • Hardware page flipping for smooth presentation
  • Efficient GPU texture-to-buffer copying
  • Advanced FPS calculation with sliding window analysis
  • Minimal memory allocations in the render loop
  • Optimized command buffer submission
  • Real-time performance monitoring

Troubleshooting

Permission Issues:

  • Run with sudo or add user to video group
  • Check /dev/dri/card* device permissions

No Display Output:

  • Verify GPU supports Vulkan
  • Check DRM device availability
  • Ensure display is connected and active

Build Issues:

  • Update Rust: rustup update
  • Check Vulkan drivers are installed

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors