Graphics and GPU rendering¶
Scope: engine-independent GPU rendering and shaders for games and other real-time 3D applications, on native platforms and on the web with WebGL and WebGPU. Engine-specific rendering rules are in Unity: rendering and shaders, Godot: rendering and shaders, Unreal Engine: rendering and shaders and GameMaker: rendering and shaders. Frame-time budgets (GAMEDEV-12) and other engine-independent game rules are in Game development, and store, thermal and download-size rules for phones are in Mobile games.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
No single guide covers every GPU. Use the guide for each GPU family you target as its baseline; much of each vendor's advice applies to the others too.
- 8 Arm GPU Best Practices Developer Guide (Arm, issue 10, January 2025, PDF): the baseline for Arm Mali and Immortalis GPUs: the optimisation process and budgets, draw calls, render passes on tile-based GPUs, shader precision, textures and compute.
- 8 Adreno GPU on Mobile: Best Practices (Qualcomm): the baseline for Qualcomm Adreno GPUs: renderer architecture, render passes and tile memory, depth testing, textures and shaders.
- 8 WebGL best practices (MDN): the baseline for WebGL: errors and limits, blocking calls, video memory budgets, batching, parallel shader compilation, precision, mipmaps and compressed textures.
- 7 Analyze and optimize game performance and CPU and GPU optimization tips (Android Developers): finding CPU and GPU bottlenecks on Android devices, and fixing common GPU problems with RenderDoc and Android GPU Inspector.
- 7 Tailor your apps for Apple GPUs and tile-based deferred rendering and Optimizing GPU performance (Apple): how Apple GPUs render, and how to find GPU bottlenecks with the Metal debugger.
- 7 RDNA Performance Guide (AMD GPUOpen, 2023): the baseline for AMD Radeon GPUs with Direct3D 12 and Vulkan: command buffers, pipeline state objects, barriers, memory and shaders.
- 7 Advanced API Performance tips (NVIDIA Technical Blog): short lists of what to do and avoid on NVIDIA GPUs with Direct3D 12 and Vulkan, one post per topic.
- 7 WebGPU API (MDN) and the WebGPU specification (W3C): the WebGPU programming model, devices, pipelines, error handling and browser support.
Key rules¶
Choosing the renderer¶
- 8
GFX-1Choose the graphics API or engine render pipeline, and the oldest hardware you will support, at the start of the project, and record the choice and the options you rejected in an ADR. Switching later means reworking shaders, materials and lighting; the ADR rules areADR-1andADR-3in Decisions. Prefer each platform's current API: Vulkan on Android, where OpenGL ES no longer gets new features, and Metal on Apple platforms, where OpenGL ES is deprecated. (Unity, Choose a render pipeline, Godot, Overview of renderers, Android, Use Vulkan for graphics, Apple, OpenGL ES)
Budgets and bottlenecks¶
- 7
GFX-2Break each platform's frame-time budget (GAMEDEV-12) down into GPU budgets for each device tier: GPU time per frame, shader cycles, triangle counts, and memory for textures, meshes and render targets. Keep the memory budget below the smallest supported device's limit: iOS terminates apps that exceed a per-device memory limit, and WebGL can't query video memory at all. (Arm GPU Best Practices, 2.1 Optimization process, Apple, Reducing the memory footprint of Metal apps, MDN, Estimate a per-pixel VRAM budget) - 7
GFX-3Before optimising, find out whether the frame is CPU-bound or GPU-bound, and which GPU stage limits it. Measure frame times in milliseconds with vsync off, not frames per second, and measure again after each change, because the bottleneck moves. Setting the frame-time budget you measure against isGAMEDEV-12. (Android, Identify CPU or GPU bottlenecks, Arm GPU Best Practices, 2.1 Optimization process, Godot, General optimization tips) - 6
GFX-4Inspect GPU frames with a frame debugger and GPU profiler for each target API: RenderDoc for Vulkan, Direct3D and OpenGL ES, PIX for Direct3D 12, the Metal debugger in Xcode for Apple GPUs, and Android GPU Inspector or the GPU vendor's profiler on Android. RenderDoc doesn't support Metal or WebGL. (RenderDoc, FAQ, Microsoft, Get started with PIX, Apple, Optimizing GPU performance, Android GPU Inspector)
Shaders and pipelines¶
- 8
GFX-5Don't compile shaders or create pipeline state objects during gameplay. Create them while loading or on background threads, and keep them between runs in a pipeline cache (VkPipelineCache, a Direct3D 12 pipeline library) or as precompiled binaries where the platform allows, such as Metal binary archives. Compiling during a frame causes hitches, and Arm, AMD and NVIDIA all advise against it. In WebGL, compile withKHR_parallel_shader_compile. (Arm GPU Best Practices, 4.1 and 4.2, AMD, RDNA Performance Guide, NVIDIA, Pipeline State Objects, Microsoft, CreatePipelineLibrary, Apple, Metal binary archives, MDN, Prefer KHR_parallel_shader_compile) - 7
GFX-6Keep the number of shader variants small and known: count them in every build, strip those no material uses, and use dynamic branching, specialization constants or an ubershader for features that don't need a variant of their own. Each independent feature switch doubles the variants, and every variant adds build time, memory and loading time. (Unity, Introduction to shader variants, AMD, RDNA Performance Guide, NVIDIA, Pipeline State Objects, Godot, Reducing stutter from shader compilations) - 7
GFX-7Compile every shader for every target API offline, in CI, and validate the output, so that a shader that fails on one platform breaks the build rather than the game. Khronos recommends that every tool that produces SPIR-V checks it with the validator, and DXC validates the DXIL it emits. (Arm GPU Best Practices, 2.2 Basic optimization checklist, Khronos, SPIRV-Tools validator, Microsoft, DirectX Shader Compiler) - 7
GFX-8Run development and automated test builds with the graphics API's validation turned on, such as the Vulkan validation layers with Best Practices, the Direct3D 12 debug layer or Metal API Validation, and fix what they report. Microsoft recommends running with the debug layer most of the time, and GPU-based validation on a few machines in a nightly test pass. (Microsoft, GPU-based validation and the Direct3D 12 debug layer, Khronos, Best Practices validation, Apple, Validating your app's Metal API usage, MDN, Address and eliminate WebGL errors) - 6
GFX-9Use 16-bit precision (mediumpor explicit 16-bit types) wherever it is accurate enough, especially in fragment shaders on mobile GPUs, and check the results on a mobile GPU, because desktop GPUs usually ignoremediump. On Adreno, 16-bit fragment shaders can be twice as fast and twice as power-efficient. (Arm GPU Best Practices, 10.1 Minimize precision, Qualcomm, Adreno best practices: half-precision, Android, Optimize shader precision)
Draw calls and overdraw¶
- 7
GFX-10Cut draw calls and state changes: cull objects outside the view on the CPU, batch or instance objects that share a material, and sort draws by pipeline state. Arm suggests fewer than about 500 draw calls per frame with OpenGL ES and 1,000 with Vulkan on its current GPUs. (Arm GPU Best Practices, 3.2 and 3.3, AMD, RDNA Performance Guide, MDN, Batch draw calls) - 6
GFX-11Draw opaque geometry front to back and transparent geometry back to front, and avoiddiscardand depth writes in fragment shaders where you can, so that early depth testing removes hidden fragments before they are shaded. (Arm GPU Best Practices, 3.4 Optimizing the draw call render order, Android, Avoid discard to enable Early-Z)
Tile-based GPUs¶
- 7
GFX-12On tile-based GPUs, which include most mobile GPUs and Apple silicon, choose every attachment's load and store action deliberately: clear or don't-care on load unless you need the previous contents, and don't-care on store for attachments you don't read later, such as depth and multisampled color, which can then be transient or memoryless. Each unneeded load or store copies the attachment between tile memory and main memory. Also merge consecutive passes that render to the same targets. (Khronos, Vulkan Guide: Tile Based Rendering best practices, Arm GPU Best Practices, 7.3 Efficient render passes with Vulkan, Apple, Setting load and store actions, Qualcomm, Adreno best practices: render pass, Android, Minimize load or store operations)
Assets¶
- 7
GFX-13Ship textures in GPU-compressed formats, with mipmaps for anything seen in 3D: ASTC, with ETC2 as the fallback, on mobile, BC formats on desktop, and on the web a format each device supports, for example by transcoding Basis Universal at load time. Compressed textures use less memory and bandwidth, and mipmaps make distant textures both faster and less aliased. (Arm GPU Best Practices, 8.4 Texture sampling performance, Android, Textures, Android, Target texture compression formats in Android App Bundles, Microsoft, Texture block compression in Direct3D 11, MDN, Consider compressed texture formats, MDN, Use mipmaps) - 6
GFX-14Give meshes that move towards and away from the camera levels of detail, with about half the triangles at each level, so that distant objects don't cost more than they show. (Android, Geometry: level of detail, Android, Optimize geometry complexity)
Web¶
- 6
GFX-15Feature-detect WebGPU and keep a WebGL 2 fallback, or use an engine that has one. WebGPU works in all major browsers, but not yet on every platform, such as Linux or Firefox on Android, andrequestAdapter()can return no adapter. (web.dev, WebGPU is now supported in major browsers, MDN, WebGPU API: accessing a device) - 6
GFX-16Handle a lost GPU context: listen forwebglcontextlostandwebglcontextrestoredin WebGL, and watchGPUDevice.lostin WebGPU, and be able to recreate every GPU resource. Browsers drop contexts when the GPU is reset, switched or overloaded, and MDN advises always handling lost devices. (MDN, isContextLost(): usage notes, MDN, GPUDevice: lost)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 6 Vulkan Best Practices validation (Khronos): part of the Khronos validation layer. It checks the app at run time, so turn it on while automated tests render frames. It warns, for example, about pipelines created without a cache, attachments loaded with
LOAD_OP_LOADor stored needlessly, attachments that should be transient, many small draw calls, and the same pipeline bound twice in a command buffer. Some checks run only when the vendor-specific checks for Arm, AMD, NVIDIA or Imagination GPUs are turned on. Partly checksGFX-5,GFX-10andGFX-12. - 6 glslang and
spirv-val(Khronos): the reference GLSL and ESSL compiler and the SPIR-V validator. Run them on every shader in CI. ChecksGFX-7for GLSL, ESSL and SPIR-V. - 6 DirectX Shader Compiler (Microsoft): compiles HLSL to validated DXIL for Direct3D 12, or to SPIR-V for Vulkan. Run
dxcon every shader and variant in CI. glslang's HLSL front end was deprecated in April 2026. ChecksGFX-7for HLSL. - 5 naga (wgpu):
naga shader.wgslvalidates a WGSL shader, and it can also translate shaders between WGSL, SPIR-V, GLSL, HLSL and MSL. ChecksGFX-7for WGSL. - 5 Mali Offline Compiler (Arm): estimates each shader's cycle cost on a chosen Mali GPU, and reports register use and the share of 16-bit arithmetic. With
--format json, a CI script can fail shaders that exceed a cycle budget. Partly checksGFX-2andGFX-9.
Tutorials and further reading¶
- 7 Vulkan Samples: performance (Khronos): runnable samples with live profiling for render passes, subpasses, pipeline caches, pipeline barriers, descriptor management and texture compression.
- 6 Vulkan Guide (Khronos): a guide to Vulkan concepts, tools and porting from OpenGL, Direct3D and Metal.
- 6 Your first WebGPU app (Google Codelabs): a step-by-step introduction to WebGPU rendering and compute shaders.