Mesa is intimidating at first—it's a huge codebase with multiple drivers, compiler infrastructure, and decades of history. But it's also well-organized once you understand the structure. Here's what I've learned while getting started with Mesa contribution.
Mesa's source tree is organized by driver and component. The main directories you'll care about:
src/amd/ — AMD-specific code (RADV, RadeonSI, ACO compiler)src/intel/ — Intel drivers and compilersrc/compiler/nir/ — NIR intermediate representationsrc/vulkan/ — Common Vulkan code shared between driverssrc/gallium/ — Gallium driver infrastructure
If you're working on AMD Vulkan (RADV), you'll spend most of your time in src/amd/vulkan/ for the driver code and
src/amd/compiler/ for ACO.
Mesa uses Meson as its build system. Basic build:
meson setup build -Dvulkan-drivers=amd -Dgallium-drivers= -Dbuildtype=debug ninja -C build
The -Dvulkan-drivers=amd builds only RADV (faster than building everything). Debug builds include symbols and assertions which
are essential when you're learning the code.
To use your custom Mesa build without installing it system-wide, set these environment variables:
export VK_ICD_FILENAMES=/path/to/build/src/amd/vulkan/radeon_icd.x86_64.json export LD_LIBRARY_PATH=/path/to/build/src/amd/vulkan:$LD_LIBRARY_PATH
Start by tracing a simple API call. For example, in RADV:
vkCreateGraphicsPipelines is in radv_pipeline.cradv_shader.caco_interface.cpp
Following the code path for one operation teaches you how the pieces fit together. Use grep and cscope liberally.
Mesa has extensive debugging infrastructure via environment variables:
RADV_DEBUG=shaders — Dumps shader assemblyRADV_DEBUG=checkir — Validates NIR after each passACO_DEBUG=validateir — Validates ACO IRNIR_PRINT=1 — Prints NIR before compilationThese are invaluable for understanding what the compiler is doing. When something breaks, comparing the shader dumps before and after your change tells you exactly what went wrong.
RenderDoc is essential for debugging graphics issues. It captures a frame, shows you every draw call, lets you inspect pipeline state, shader inputs/outputs, and even debug shaders step-by-step.
When a game renders incorrectly, RenderDoc shows you which draw call is wrong, what shaders are running, what textures are bound, etc. Much faster than print debugging.
Start small. Look for:
My first kernel patch was fixing old unused code that generated warnings. Trivial fix, but it taught me the patch submission workflow and how to respond to maintainer feedback.
For Mesa, the process is:
meson test to verify you didn't break anythingBe prepared for feedback. Maintainers will ask you to change things, restructure commits, or explain your reasoning. This is normal and how you learn to write better code.
Join the Matrix channels:
#radv:matrix.org — RADV development#dri-devel:matrix.org — General Mesa development#nir:matrix.org — Compiler discussionsDon't be afraid to ask questions. The community is helpful as long as you've done your homework first (read the code, tried debugging, searched the issue tracker).
I'm currently studying ACO's register allocator and instruction scheduler. The code is cleaner than I expected—good variable names, reasonable comments, clear structure.
What's interesting is seeing compiler theory applied to real hardware constraints. Textbook compiler courses teach you register allocation as graph coloring, but ACO has to deal with:
The gap between theory and practice is where interesting problems live.