Hands On Projects For The Linux Graphics Subsystem ❲Limited Time❳

Goal: Render a colored gradient or a bouncing square directly on the display using the Kernel Mode Setting (KMS) API, without any display server.

Why this matters: KMS is the foundation. It sets the resolution, depth, and scanout buffer. Everything else (Xorg, Wayland compositors) sits on top of it.

  • Checkpoints:
  • Learning outcomes:

  • Checkpoints:
  • Learning outcomes:

  • Extension: Use perf to measure how many nanoseconds your printf adds to the shader compile time. Hands On Projects For The Linux Graphics Subsystem


    #include <fcntl.h>
    #include <xf86drm.h>
    #include <xf86drmMode.h>
    int main() 
        int fd = open("/dev/dri/card0", O_RDWR);
        drmModeRes *res = drmModeGetResources(fd);
        struct drm_mode_create_dumb create = 
            .width = 1024, .height = 768, .bpp = 32
        ;
        drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create);
        printf("Dumb buffer size: %d bytes, pitch: %d\n", create.size, create.pitch);
        return 0;
    

    Goal: Render a window using the native Wayland protocol. Why: Wayland is the modern replacement for X11. Unlike X11, Wayland does not handle drawing; it acts purely as a compositor. You must handle your own buffers.

    Steps:


    Goal: Trace which process is leaking GPU memory by hooking into the Graphics Execution Manager (GEM) via ftrace or a custom LD_PRELOAD library.

    Why this matters: GEM manages buffer objects shared between the CPU and GPU. Leaks here cause "GPU reset" errors or system freezes. Goal: Render a colored gradient or a bouncing

    Goal: Simulate a monitor unplug/replug and manually reinitialize the display pipeline using only sysfs and debugfs.

    Why this matters: Hot-plug handling is where DRM, user-space compositors, and event loops meet. Checkpoints:

    Menu