How intel/gmmlib works
Purpose and consumers
GmmLib is a C/C++ graphics-memory management library, built as libigdgmm for Intel’s OpenCL Compute Runtime and VAAPI Media Driver. It supplies GPU-platform-specific resource layout, allocation metadata, cache policy, tiling/swizzle, and translation-table management; it is not a standalone application.
Build and public entry boundary
CMake is the primary build entry point; Android also has a Blueprint entry. The library’s installed/public API is separated from implementation headers.
• CMakeLists.txt
• Android.bp
• Source/GmmLib/CMakeLists.txt
• Source/GmmLib/inc/GmmLib.h
• Source/GmmLib/inc/External/Common/GmmResourceInfo.h
Linux is the currently supported runtime target, including Linux-specific resource wrappers and package metadata.
• Source/GmmLib/Linux.cmake
• Source/GmmLib/igdgmm.h.in
• Source/GmmLib/igdgmm.pc.in
Context and platform dispatch
Clients create/use a GMM client context and global information layer, which identifies platform/SKU characteristics and selects generation-specific behavior. This is the main control boundary between stable external API objects and internal hardware implementations.
• Source/GmmLib/GlobalInfo/GmmClientContext.cpp
• Source/GmmLib/GlobalInfo/GmmInfo.cpp
• Source/GmmLib/Platform/GmmPlatform.cpp
• Source/GmmLib/Platform/GmmPlatforms.h
Per-generation platform implementations cover Gen8 through Gen12 in this tree; newer Xe-family specialization is visible primarily in cache-policy and texture paths.
• Source/GmmLib/Platform/GmmGen8Platform.cpp
• Source/GmmLib/Platform/GmmGen12Platform.cpp
Resource-description and layout pipeline
The primary data flow starts with client resource descriptors/flags, then computes restrictions, size/alignment, pitch, offsets, tiling, and associated metadata. GmmResourceInfoCommon centralizes generic behavior while platform texture calculators provide hardware-specific layout rules.
• Source/GmmLib/Resource/GmmResourceInfo.cpp
• Source/GmmLib/Resource/GmmResourceInfoCommon.cpp
• Source/GmmLib/Resource/GmmRestrictions.cpp
• Source/GmmLib/Texture/GmmTexture.cpp
• Source/GmmLib/Texture/GmmTextureAlloc.cpp
Generation-specific texture calculation is the key hardware boundary for surfaces.
• Source/GmmLib/Texture/GmmGen12Texture.cpp
• Source/GmmLib/Texture/GmmXe_LPGTexture.cpp
• Source/GmmLib/inc/Internal/Common/Texture/GmmTextureCalc.h
Cache-policy resolution
Resource usage and platform capabilities are translated into cacheability/memory-object-control policy. Common policy code is extended by separate implementations for Intel generations and Xe variants, so changes here can affect all client resource programming.
• Source/GmmLib/CachePolicy/GmmCachePolicy.cpp
• Source/GmmLib/CachePolicy/GmmCachePolicyCommon.cpp
• Source/GmmLib/CachePolicy/GmmGen12CachePolicy.cpp
• Source/GmmLib/CachePolicy/GmmXe3P_XPCCachePolicy.cpp
Address translation and auxiliary metadata
Translation-table components manage GPU virtual-address mappings and auxiliary/compression-related tables. They sit downstream of resource creation and expose page-table/auxiliary-table integration points to user-mode consumers.
• Source/GmmLib/TranslationTable/GmmPageTableMgr.cpp
• Source/GmmLib/TranslationTable/GmmAuxTable.cpp
• Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp
OS integration, diagnostics, and validation
Linux exposes a C wrapper around resource information; CPU swizzle blits support CPU-side access/layout conversion. Diagnostics include assertion tracing and bundled spdlog; neither is the stable client ABI.
• Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp
• Source/GmmLib/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c
• Source/Common/AssertTracer/AssertTracer.cpp
• Source/GmmLib/Utility/GmmLog/GmmLog.cpp
Unit-level tests compile with the library and cover resource, cache-policy, and translation behavior using vendored GoogleTest.
• Source/GmmLib/ULT/CMakeLists.txt
• Source/GmmLib/ULT/GmmULT.cpp
Main entry points: GmmResourceInfoCommon.cpp Resource info core · GmmPlatform.cpp Platform dispatch · GmmResourceInfo.h Public resource API · GmmTexture.cpp Texture layout pipeline
Components 18
Build & Distribution
- CMake build · Primary build for libigdgmm.
CMakeLists.txt - Android Blueprint
Android.bp - Linux packaging
Source/GmmLib/Linux.cmake
Public Context & Platform
- Public resource API · Stable resource-information interface for runtime clients.
Source/GmmLib/inc/External/Common/GmmResourceInfo.h - Client context · Connects external API usage to platform-specific internals.
Source/GmmLib/GlobalInfo/GmmClientContext.cpp - Global platform info
Source/GmmLib/GlobalInfo/GmmInfo.cpp - Platform dispatch · Selects SKU and GPU-generation behavior.
Source/GmmLib/Platform/GmmPlatform.cpp
Resource Layout & Policy
- Resource info core · Owns generic resource layout and allocation metadata behavior.
Source/GmmLib/Resource/GmmResourceInfoCommon.cpp - Resource restrictions
Source/GmmLib/Resource/GmmRestrictions.cpp - Texture layout pipeline · Calculates size, alignment, pitch, offsets, tiling, and metadata.
Source/GmmLib/Texture/GmmTexture.cpp - Gen12/Xe texture rules · Generation-specific surface calculation boundary.
Source/GmmLib/Texture/GmmGen12Texture.cpp - Cache policy core · Resolves usage and capabilities into cacheability policy.
Source/GmmLib/CachePolicy/GmmCachePolicyCommon.cpp - Gen/Xe cache policy
Source/GmmLib/CachePolicy/GmmGen12CachePolicy.cpp - Translation tables · Manages page-table mappings and auxiliary-table integration.
Source/GmmLib/TranslationTable/GmmUmdTranslationTable.cpp
Integration & Support
- Linux resource wrapper
Source/GmmLib/Resource/Linux/GmmResourceInfoLinCWrapper.cpp - CPU swizzle blit
Source/GmmLib/Utility/CpuSwizzleBlt/CpuSwizzleBlt.c - Diagnostics · Internal tracing and logging, outside the stable ABI.
Source/GmmLib/Utility/GmmLog/GmmLog.cpp
Other components
- OpenCL Runtime & VAAPI · User-mode clients link against libigdgmm.
Connections 21
- CMake build → Public resource API: builds library API
- CMake build → Linux packaging: Linux target
- Android Blueprint → Public resource API: builds
- OpenCL Runtime & VAAPI → Public resource API: uses
- Public resource API → Client context: creates and queries
- Client context → Global platform info: initializes
- Global platform info → Platform dispatch: identifies platform
- Platform dispatch → Resource info core: configures behavior
- Platform dispatch → Gen12/Xe texture rules: selects layout rules
- Platform dispatch → Gen/Xe cache policy: selects policy rules
- Client context → Resource info core: creates resource metadata
- Resource info core → Resource restrictions: applies constraints
- Resource info core → Texture layout pipeline: computes layout
- Resource restrictions → Texture layout pipeline: constrains
- Gen12/Xe texture rules → Texture layout pipeline: provides hardware calculations
- Resource info core → Cache policy core: resolves usage policy
- Gen/Xe cache policy → Cache policy core: extends
- Resource info core → Translation tables: supplies allocation metadata
- Linux resource wrapper → Resource info core: wraps for Linux C clients
- CPU swizzle blit → Texture layout pipeline: converts CPU-visible layouts
- Resource info core → Diagnostics: reports diagnostics