1*61046927SAndroid Build Coastguard WorkerIntel Surface Layout 2*61046927SAndroid Build Coastguard Worker 3*61046927SAndroid Build Coastguard WorkerIntroduction 4*61046927SAndroid Build Coastguard Worker============ 5*61046927SAndroid Build Coastguard Workerisl is a small library that calculates the layout of Intel GPU surfaces, queries 6*61046927SAndroid Build Coastguard Workerthose layouts, and queries the properties of surface formats. 7*61046927SAndroid Build Coastguard Worker 8*61046927SAndroid Build Coastguard Worker 9*61046927SAndroid Build Coastguard WorkerIndependence from User APIs 10*61046927SAndroid Build Coastguard Worker=========================== 11*61046927SAndroid Build Coastguard Workerisl's API is independent of any user-facing graphics API, such as OpenGL and 12*61046927SAndroid Build Coastguard WorkerVulkan. This independence allows isl to be used a shared component by multiple 13*61046927SAndroid Build Coastguard WorkerIntel drivers. 14*61046927SAndroid Build Coastguard Worker 15*61046927SAndroid Build Coastguard WorkerRather than mimic the user-facing APIs, the isl API attempts to reflect Intel 16*61046927SAndroid Build Coastguard Workerhardware: the actual memory layout of Intel GPU surfaces and how one programs 17*61046927SAndroid Build Coastguard Workerthe GPU to use those surfaces. For example: 18*61046927SAndroid Build Coastguard Worker 19*61046927SAndroid Build Coastguard Worker - The tokens of `enum isl_format` (such as `ISL_FORMAT_R8G8B8A8_UNORM`) 20*61046927SAndroid Build Coastguard Worker match those of the hardware enum `SURFACE_FORMAT` rather than the OpenGL 21*61046927SAndroid Build Coastguard Worker or Vulkan format tokens. And the values of `isl_format` and 22*61046927SAndroid Build Coastguard Worker `SURFACE_FORMAT` are identical. 23*61046927SAndroid Build Coastguard Worker 24*61046927SAndroid Build Coastguard Worker - The OpenGL and Vulkan APIs contain depth and stencil formats. However the 25*61046927SAndroid Build Coastguard Worker hardware enum `SURFACE_FORMAT` does not, and therefore neither does `enum 26*61046927SAndroid Build Coastguard Worker isl_format`. Rather than define new pixel formats that have no hardware 27*61046927SAndroid Build Coastguard Worker counterpart, isl records the intent to use a surface as a depth or stencil 28*61046927SAndroid Build Coastguard Worker buffer with the usage flags `ISL_SURF_USAGE_DEPTH_BIT` and 29*61046927SAndroid Build Coastguard Worker `ISL_SURF_USAGE_STENCIL_BIT`. 30*61046927SAndroid Build Coastguard Worker 31*61046927SAndroid Build Coastguard Worker - `struct isl_surf` distinguishes between the surface's logical dimension 32*61046927SAndroid Build Coastguard Worker from the user API's perspective (`enum isl_surf_dim`, which may be 1D, 2D, 33*61046927SAndroid Build Coastguard Worker or 3D) and the layout of those dimensions in memory (`enum isl_dim_layout`). 34*61046927SAndroid Build Coastguard Worker 35*61046927SAndroid Build Coastguard Worker 36*61046927SAndroid Build Coastguard WorkerSurface Units 37*61046927SAndroid Build Coastguard Worker============= 38*61046927SAndroid Build Coastguard Worker 39*61046927SAndroid Build Coastguard WorkerIntro 40*61046927SAndroid Build Coastguard Worker----- 41*61046927SAndroid Build Coastguard WorkerISL takes care in its equations to correctly handle conversion among surface 42*61046927SAndroid Build Coastguard Workerunits (such as pixels and compression blocks) and to carefully distinguish 43*61046927SAndroid Build Coastguard Workerbetween a surface's logical layout in the client API and its physical layout 44*61046927SAndroid Build Coastguard Workerin memory. 45*61046927SAndroid Build Coastguard Worker 46*61046927SAndroid Build Coastguard WorkerSymbol names often explicitly declare their unit with a suffix: 47*61046927SAndroid Build Coastguard Worker 48*61046927SAndroid Build Coastguard Worker - px: logical pixels 49*61046927SAndroid Build Coastguard Worker - sa: physical surface samples 50*61046927SAndroid Build Coastguard Worker - el: physical surface elements 51*61046927SAndroid Build Coastguard Worker - sa_rows: rows of physical surface samples 52*61046927SAndroid Build Coastguard Worker - el_rows: rows of physical surface elements 53*61046927SAndroid Build Coastguard Worker 54*61046927SAndroid Build Coastguard WorkerLogical units are independent of hardware generation and are closely related 55*61046927SAndroid Build Coastguard Workerto the user-facing API (OpenGL and Vulkan). Physical units are dependent on 56*61046927SAndroid Build Coastguard Workerhardware generation and reflect the surface's layout in memory. 57*61046927SAndroid Build Coastguard Worker 58*61046927SAndroid Build Coastguard WorkerDefinitions 59*61046927SAndroid Build Coastguard Worker----------- 60*61046927SAndroid Build Coastguard Worker- Logical Pixels (px): 61*61046927SAndroid Build Coastguard Worker 62*61046927SAndroid Build Coastguard Worker The surface's layout from the perspective of the client API (OpenGL and 63*61046927SAndroid Build Coastguard Worker Vulkan) is in units of logical pixels. Logical pixels are independent of the 64*61046927SAndroid Build Coastguard Worker surface's layout in memory. 65*61046927SAndroid Build Coastguard Worker 66*61046927SAndroid Build Coastguard Worker A surface's width and height, in units of logical pixels, is not affected by 67*61046927SAndroid Build Coastguard Worker the surface's sample count. For example, consider a VkImage created with 68*61046927SAndroid Build Coastguard Worker VkImageCreateInfo{width=w0, height=h0, samples=s0}. The surface's width and 69*61046927SAndroid Build Coastguard Worker height at level 0 is, in units of logical pixels, w0 and h0 regardless of 70*61046927SAndroid Build Coastguard Worker the value of s0. 71*61046927SAndroid Build Coastguard Worker 72*61046927SAndroid Build Coastguard Worker For example, the logical array length of a 3D surface is always 1, even on 73*61046927SAndroid Build Coastguard Worker Gfx9 where the surface's memory layout is that of an array surface 74*61046927SAndroid Build Coastguard Worker (ISL_DIM_LAYOUT_GFX4_2D). 75*61046927SAndroid Build Coastguard Worker 76*61046927SAndroid Build Coastguard Worker- Physical Surface Samples (sa): 77*61046927SAndroid Build Coastguard Worker 78*61046927SAndroid Build Coastguard Worker For a multisampled surface, this unit has the obvious meaning. 79*61046927SAndroid Build Coastguard Worker A singlesampled surface, from ISL's perspective, is simply a multisampled 80*61046927SAndroid Build Coastguard Worker surface whose sample count is 1. 81*61046927SAndroid Build Coastguard Worker 82*61046927SAndroid Build Coastguard Worker For example, consider a 2D single-level non-array surface with samples=4, 83*61046927SAndroid Build Coastguard Worker width_px=64, and height_px=64 (note that the suffix 'px' indicates logical 84*61046927SAndroid Build Coastguard Worker pixels). If the surface's multisample layout is ISL_MSAA_LAYOUT_INTERLEAVED, 85*61046927SAndroid Build Coastguard Worker then the extent of level 0 is, in units of physical surface samples, 86*61046927SAndroid Build Coastguard Worker width_sa=128, height_sa=128, depth_sa=1, array_length_sa=1. If 87*61046927SAndroid Build Coastguard Worker ISL_MSAA_LAYOUT_ARRAY, then width_sa=64, height_sa=64, depth_sa=1, 88*61046927SAndroid Build Coastguard Worker array_length_sa=4. 89*61046927SAndroid Build Coastguard Worker 90*61046927SAndroid Build Coastguard Worker- Physical Surface Elements (el): 91*61046927SAndroid Build Coastguard Worker 92*61046927SAndroid Build Coastguard Worker This unit allows ISL to treat compressed and uncompressed formats 93*61046927SAndroid Build Coastguard Worker identically in many calculations. 94*61046927SAndroid Build Coastguard Worker 95*61046927SAndroid Build Coastguard Worker If the surface's pixel format is compressed, such as ETC2, then a surface 96*61046927SAndroid Build Coastguard Worker element is equivalent to a compression block. If uncompressed, then 97*61046927SAndroid Build Coastguard Worker a surface element is equivalent to a surface sample. As a corollary, for 98*61046927SAndroid Build Coastguard Worker a given surface a surface element is at least as large as a surface sample. 99*61046927SAndroid Build Coastguard Worker 100*61046927SAndroid Build Coastguard WorkerErrata 101*61046927SAndroid Build Coastguard Worker------ 102*61046927SAndroid Build Coastguard WorkerISL acquired the term 'surface element' from the Broadwell PRM [1], which 103*61046927SAndroid Build Coastguard Workerdefines it as follows: 104*61046927SAndroid Build Coastguard Worker 105*61046927SAndroid Build Coastguard Worker An element is defined as a pixel in uncompressed surface formats, and as 106*61046927SAndroid Build Coastguard Worker a compression block in compressed surface formats. For MSFMT_DEPTH_STENCIL 107*61046927SAndroid Build Coastguard Worker type multisampled surfaces, an element is a sample. 108*61046927SAndroid Build Coastguard Worker 109*61046927SAndroid Build Coastguard Worker 110*61046927SAndroid Build Coastguard WorkerReferences 111*61046927SAndroid Build Coastguard Worker========== 112*61046927SAndroid Build Coastguard Worker[1]: Broadwell PRM >> Volume 2d: Command Reference: Structures >> 113*61046927SAndroid Build Coastguard Worker RENDER_SURFACE_STATE Surface Vertical Alignment (p325) 114