1*61046927SAndroid Build Coastguard WorkerAsahi 2*61046927SAndroid Build Coastguard Worker===== 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard WorkerThe Asahi driver aims to provide an OpenGL implementation for the Apple M1. 5*61046927SAndroid Build Coastguard Worker 6*61046927SAndroid Build Coastguard WorkerWrap (macOS only) 7*61046927SAndroid Build Coastguard Worker----------------- 8*61046927SAndroid Build Coastguard Worker 9*61046927SAndroid Build Coastguard WorkerMesa includes a library that wraps the key IOKit entrypoints used in the macOS 10*61046927SAndroid Build Coastguard WorkerUABI for AGX. The wrapped routines print information about the kernel calls made 11*61046927SAndroid Build Coastguard Workerand dump work submitted to the GPU using agxdecode. This facilitates 12*61046927SAndroid Build Coastguard Workerreverse-engineering the hardware, as glue to get at the "interesting" GPU 13*61046927SAndroid Build Coastguard Workermemory. 14*61046927SAndroid Build Coastguard Worker 15*61046927SAndroid Build Coastguard WorkerThe library is only built if ``-Dtools=asahi`` is passed. It builds a single 16*61046927SAndroid Build Coastguard Worker``wrap.dylib`` file, which should be inserted into a process with the 17*61046927SAndroid Build Coastguard Worker``DYLD_INSERT_LIBRARIES`` environment variable. 18*61046927SAndroid Build Coastguard Worker 19*61046927SAndroid Build Coastguard WorkerFor example, to trace an app ``./app``, run: 20*61046927SAndroid Build Coastguard Worker 21*61046927SAndroid Build Coastguard Worker DYLD_INSERT_LIBRARIES=~/mesa/build/src/asahi/lib/libwrap.dylib ./app 22*61046927SAndroid Build Coastguard Worker 23*61046927SAndroid Build Coastguard WorkerHardware varyings 24*61046927SAndroid Build Coastguard Worker----------------- 25*61046927SAndroid Build Coastguard Worker 26*61046927SAndroid Build Coastguard WorkerAt an API level, vertex shader outputs need to be interpolated to become 27*61046927SAndroid Build Coastguard Workerfragment shader inputs. This process is logically pipelined in AGX, with a value 28*61046927SAndroid Build Coastguard Workertraveling from a vertex shader to remapping hardware to coefficient register 29*61046927SAndroid Build Coastguard Workersetup to the fragment shader to the iterator hardware. Each stage is described 30*61046927SAndroid Build Coastguard Workerbelow. 31*61046927SAndroid Build Coastguard Worker 32*61046927SAndroid Build Coastguard WorkerVertex shader 33*61046927SAndroid Build Coastguard Worker````````````` 34*61046927SAndroid Build Coastguard Worker 35*61046927SAndroid Build Coastguard WorkerA vertex shader (running on the :term:`Unified Shader Cores`) outputs varyings with the 36*61046927SAndroid Build Coastguard Worker``st_var`` instruction. ``st_var`` takes a *vertex output index* and a 32-bit 37*61046927SAndroid Build Coastguard Workervalue. The maximum number of *vertex outputs* is specified as the "output count" 38*61046927SAndroid Build Coastguard Workerof the shader in the "Bind Vertex Pipeline" packet. The value may be interpreted 39*61046927SAndroid Build Coastguard Workerconsist of a single 32-bit value or an aligned 16-bit register pair, depending 40*61046927SAndroid Build Coastguard Workeron whether interpolation should happen at 32-bit or 16-bit. Vertex outputs are 41*61046927SAndroid Build Coastguard Workerindexed starting from 0, with the *vertex position* always coming first, the 42*61046927SAndroid Build Coastguard Worker32-bit user varyings coming next with perspective, flat, and linear interpolated 43*61046927SAndroid Build Coastguard Workervaryings grouped in that order, then 16-bit user varyings with the same groupings, 44*61046927SAndroid Build Coastguard Workerand finally *point size* and *clip distances* at the end if present. Note that 45*61046927SAndroid Build Coastguard Worker*clip distances* are not accessible from the fragment shader; if the fragment 46*61046927SAndroid Build Coastguard Workershader needs to read the interpolated clip distance, the vertex shader must 47*61046927SAndroid Build Coastguard Worker*also* write the clip distance values to a user varying for the fragment shader 48*61046927SAndroid Build Coastguard Workerto interpolate. Also note there is no clip plane enable mask anywhere; that must 49*61046927SAndroid Build Coastguard Workerlowered for APIs that require this (OpenGL but not Vulkan). 50*61046927SAndroid Build Coastguard Worker 51*61046927SAndroid Build Coastguard Worker.. list-table:: Ordering of vertex outputs with all outputs used 52*61046927SAndroid Build Coastguard Worker :widths: 25 75 53*61046927SAndroid Build Coastguard Worker :header-rows: 1 54*61046927SAndroid Build Coastguard Worker 55*61046927SAndroid Build Coastguard Worker * - Size (words) 56*61046927SAndroid Build Coastguard Worker - Value 57*61046927SAndroid Build Coastguard Worker * - 4 58*61046927SAndroid Build Coastguard Worker - Vertex position 59*61046927SAndroid Build Coastguard Worker * - 1 60*61046927SAndroid Build Coastguard Worker - 32-bit smooth varying 0 61*61046927SAndroid Build Coastguard Worker * - 62*61046927SAndroid Build Coastguard Worker - ... 63*61046927SAndroid Build Coastguard Worker * - 1 64*61046927SAndroid Build Coastguard Worker - 32-bit smooth varying m 65*61046927SAndroid Build Coastguard Worker * - 1 66*61046927SAndroid Build Coastguard Worker - 32-bit flat varying 0 67*61046927SAndroid Build Coastguard Worker * - 68*61046927SAndroid Build Coastguard Worker - ... 69*61046927SAndroid Build Coastguard Worker * - 1 70*61046927SAndroid Build Coastguard Worker - 32-bit flat varying n 71*61046927SAndroid Build Coastguard Worker * - 1 72*61046927SAndroid Build Coastguard Worker - 32-bit linear varying 0 73*61046927SAndroid Build Coastguard Worker * - 74*61046927SAndroid Build Coastguard Worker - ... 75*61046927SAndroid Build Coastguard Worker * - 1 76*61046927SAndroid Build Coastguard Worker - 32-bit linear varying o 77*61046927SAndroid Build Coastguard Worker * - 1 78*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit smooth varyings 0 79*61046927SAndroid Build Coastguard Worker * - 80*61046927SAndroid Build Coastguard Worker - ... 81*61046927SAndroid Build Coastguard Worker * - 1 82*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit smooth varyings p 83*61046927SAndroid Build Coastguard Worker * - 1 84*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit flat varyings 0 85*61046927SAndroid Build Coastguard Worker * - 86*61046927SAndroid Build Coastguard Worker - ... 87*61046927SAndroid Build Coastguard Worker * - 1 88*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit flat varyings q 89*61046927SAndroid Build Coastguard Worker * - 1 90*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit linear varyings 0 91*61046927SAndroid Build Coastguard Worker * - 92*61046927SAndroid Build Coastguard Worker - ... 93*61046927SAndroid Build Coastguard Worker * - 1 94*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit linear varyings r 95*61046927SAndroid Build Coastguard Worker * - 1 96*61046927SAndroid Build Coastguard Worker - Point size 97*61046927SAndroid Build Coastguard Worker * - 1 98*61046927SAndroid Build Coastguard Worker - Clip distance for plane 0 99*61046927SAndroid Build Coastguard Worker * - 100*61046927SAndroid Build Coastguard Worker - ... 101*61046927SAndroid Build Coastguard Worker * - 1 102*61046927SAndroid Build Coastguard Worker - Clip distance for plane 15 103*61046927SAndroid Build Coastguard Worker 104*61046927SAndroid Build Coastguard WorkerRemapping 105*61046927SAndroid Build Coastguard Worker````````` 106*61046927SAndroid Build Coastguard Worker 107*61046927SAndroid Build Coastguard WorkerVertex outputs are remapped to varying slots to be interpolated. 108*61046927SAndroid Build Coastguard WorkerThe output of remapping consists of the following items: the *W* fragment 109*61046927SAndroid Build Coastguard Workercoordinate, the *Z* fragment coordinate, user varyings in the vertex 110*61046927SAndroid Build Coastguard Workeroutput order. *Z* may be omitted, but *W* may not be. This remapping is 111*61046927SAndroid Build Coastguard Workerconfigured by the "Output select" word. 112*61046927SAndroid Build Coastguard Worker 113*61046927SAndroid Build Coastguard Worker.. list-table:: Ordering of remapped slots 114*61046927SAndroid Build Coastguard Worker :widths: 25 75 115*61046927SAndroid Build Coastguard Worker :header-rows: 1 116*61046927SAndroid Build Coastguard Worker 117*61046927SAndroid Build Coastguard Worker * - Index 118*61046927SAndroid Build Coastguard Worker - Value 119*61046927SAndroid Build Coastguard Worker * - 0 120*61046927SAndroid Build Coastguard Worker - Fragment coord W 121*61046927SAndroid Build Coastguard Worker * - 1 122*61046927SAndroid Build Coastguard Worker - Fragment coord Z 123*61046927SAndroid Build Coastguard Worker * - 2 124*61046927SAndroid Build Coastguard Worker - 32-bit varying 0 125*61046927SAndroid Build Coastguard Worker * - 126*61046927SAndroid Build Coastguard Worker - ... 127*61046927SAndroid Build Coastguard Worker * - 2 + m 128*61046927SAndroid Build Coastguard Worker - 32-bit varying m 129*61046927SAndroid Build Coastguard Worker * - 2 + m + 1 130*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit varyings 0 131*61046927SAndroid Build Coastguard Worker * - 132*61046927SAndroid Build Coastguard Worker - ... 133*61046927SAndroid Build Coastguard Worker * - 2 + m + n + 1 134*61046927SAndroid Build Coastguard Worker - Packed pair of 16-bit varyings n 135*61046927SAndroid Build Coastguard Worker 136*61046927SAndroid Build Coastguard WorkerCoefficient registers 137*61046927SAndroid Build Coastguard Worker````````````````````` 138*61046927SAndroid Build Coastguard Worker 139*61046927SAndroid Build Coastguard WorkerThe fragment shader does not see the physical slots. 140*61046927SAndroid Build Coastguard WorkerInstead, it references varyings through *coefficient registers*. A coefficient 141*61046927SAndroid Build Coastguard Workerregister is a register allocated constant for all fragment shader invocations in 142*61046927SAndroid Build Coastguard Workera given polygon. Physically, it contains the values output by the vertex shader 143*61046927SAndroid Build Coastguard Workerfor each vertex of the polygon. Coefficient registers are preloaded with values 144*61046927SAndroid Build Coastguard Workerfrom varying slots. This preloading appears to occur in fixed function hardware, 145*61046927SAndroid Build Coastguard Workera simplification from PowerVR which requires a specialized program for the 146*61046927SAndroid Build Coastguard Workerprogrammable data sequencer to do the preload. 147*61046927SAndroid Build Coastguard Worker 148*61046927SAndroid Build Coastguard WorkerThe "Bind fragment pipeline" packet points to coefficient register bindings, 149*61046927SAndroid Build Coastguard Workerpreceded by a header. The header contains the number of 32-bit varying slots. As 150*61046927SAndroid Build Coastguard Workerthe *W* slot is always present, this field is always nonzero. Slots whose index 151*61046927SAndroid Build Coastguard Workeris below this count are treated as 32-bit. The remaining slots are treated as 152*61046927SAndroid Build Coastguard Worker16-bits. 153*61046927SAndroid Build Coastguard Worker 154*61046927SAndroid Build Coastguard WorkerThe header also contains the total number of coefficient registers bound. 155*61046927SAndroid Build Coastguard Worker 156*61046927SAndroid Build Coastguard WorkerEach binding that follows maps a (vector of) varying slots to a (consecutive) 157*61046927SAndroid Build Coastguard Workercoefficient registers. Some details about the varying (perspective 158*61046927SAndroid Build Coastguard Workerinterpolation, flat shading, point sprites) are configured here. 159*61046927SAndroid Build Coastguard Worker 160*61046927SAndroid Build Coastguard WorkerCoefficient registers may be ordered the same as the internal varying slots. 161*61046927SAndroid Build Coastguard WorkerHowever, this may be inconvenient for some APIs that require a separable shader 162*61046927SAndroid Build Coastguard Workermodel. For these APIs, the flexibility to mix-and-match slots and coefficient 163*61046927SAndroid Build Coastguard Workerregisters allows mixing shaders without shader variants. In that case, the 164*61046927SAndroid Build Coastguard Workerbindings should be generated outside of the compiler. For simple APIs where the 165*61046927SAndroid Build Coastguard Workerbindings are fixed and known at compile-time, the bindings could be generated 166*61046927SAndroid Build Coastguard Workerwithin the compiler. 167*61046927SAndroid Build Coastguard Worker 168*61046927SAndroid Build Coastguard WorkerFragment shader 169*61046927SAndroid Build Coastguard Worker``````````````` 170*61046927SAndroid Build Coastguard Worker 171*61046927SAndroid Build Coastguard WorkerIn the fragment shader, coefficient registers, identified by the prefix ``cf`` 172*61046927SAndroid Build Coastguard Workerfollowed by a decimal index, act as opaque handles to varyings. For flat 173*61046927SAndroid Build Coastguard Workershading, coefficient registers may be loaded into general registers with the 174*61046927SAndroid Build Coastguard Worker``ldcf`` instruction. For smooth shading, the coefficient register corresponding 175*61046927SAndroid Build Coastguard Workerto the desired varying is passed as an argument to the "iterate" instruction 176*61046927SAndroid Build Coastguard Worker``iter`` in order to "iterate" (interpolate) a varying. As perspective correct 177*61046927SAndroid Build Coastguard Workerinterpolation also requires the W component of the fragment coordinate, the 178*61046927SAndroid Build Coastguard Workercoefficient register for W is passed as a second argument. As an example, if 179*61046927SAndroid Build Coastguard Workerthere's a single varying to interpolate, an instruction like ``iter r0, cf1, cf0`` 180*61046927SAndroid Build Coastguard Workeris used. 181*61046927SAndroid Build Coastguard Worker 182*61046927SAndroid Build Coastguard WorkerIterator 183*61046927SAndroid Build Coastguard Worker```````` 184*61046927SAndroid Build Coastguard Worker 185*61046927SAndroid Build Coastguard WorkerTo actually interpolate varyings, AGX provides fixed-function iteration hardware 186*61046927SAndroid Build Coastguard Workerto multiply the specified coefficient registers with the required barycentrics, 187*61046927SAndroid Build Coastguard Workerproducing an interpolated value, hence the name "coefficient register". This 188*61046927SAndroid Build Coastguard Workeroperation is purely mathematical and does not require any memory access, as 189*61046927SAndroid Build Coastguard Workerthe required coefficients are preloaded before the shader begins execution. 190*61046927SAndroid Build Coastguard WorkerThat means the iterate instruction executes in constant time, does not signal 191*61046927SAndroid Build Coastguard Workera data fence, and does not require the shader to wait on a data fence before 192*61046927SAndroid Build Coastguard Workerusing the value. 193*61046927SAndroid Build Coastguard Worker 194*61046927SAndroid Build Coastguard WorkerImage layouts 195*61046927SAndroid Build Coastguard Worker------------- 196*61046927SAndroid Build Coastguard Worker 197*61046927SAndroid Build Coastguard WorkerAGX supports several image layouts, described here. To work with image layouts 198*61046927SAndroid Build Coastguard Workerin the drivers, use the ail library, located in ``src/asahi/layout``. 199*61046927SAndroid Build Coastguard Worker 200*61046927SAndroid Build Coastguard WorkerThe simplest layout is **strided linear**. Pixels are stored in raster-order in 201*61046927SAndroid Build Coastguard Workermemory with a software-controlled stride. Strided linear images are useful for 202*61046927SAndroid Build Coastguard Workerworking with modifier-unaware window systems, however performance will suffer. 203*61046927SAndroid Build Coastguard WorkerStrided linear images have numerous limitations: 204*61046927SAndroid Build Coastguard Worker 205*61046927SAndroid Build Coastguard Worker- Strides must be a multiple of 16 bytes. 206*61046927SAndroid Build Coastguard Worker- Strides must be nonzero. For 1D images where the stride is logically 207*61046927SAndroid Build Coastguard Worker irrelevant, ail will internally select the minimal stride. 208*61046927SAndroid Build Coastguard Worker- Only 1D, 2D, and 2D Array images may be linear. In particular, no 3D or cubemaps. 209*61046927SAndroid Build Coastguard Worker- 2D images must not be mipmapped. 210*61046927SAndroid Build Coastguard Worker- Block-compressed formats and multisampled images are unsupported. Elements of 211*61046927SAndroid Build Coastguard Worker a strided linear image are simply pixels. 212*61046927SAndroid Build Coastguard Worker 213*61046927SAndroid Build Coastguard WorkerWith these limitations, addressing into a strided linear image is as simple as 214*61046927SAndroid Build Coastguard Worker 215*61046927SAndroid Build Coastguard Worker.. math:: 216*61046927SAndroid Build Coastguard Worker 217*61046927SAndroid Build Coastguard Worker \text{address} = (y \cdot \text{stride}) + (x \cdot \text{bytes per pixel}) 218*61046927SAndroid Build Coastguard Worker 219*61046927SAndroid Build Coastguard WorkerIn practice, this suffices for window system integration and little else. 220*61046927SAndroid Build Coastguard Worker 221*61046927SAndroid Build Coastguard WorkerThe most common uncompressed layout is **twiddled**. The image is divided into 222*61046927SAndroid Build Coastguard Workerpower-of-two sized tiles. The tiles themselves are stored in raster-order. 223*61046927SAndroid Build Coastguard WorkerWithin each tile, elements (pixels/blocks) are stored in Morton (Z) order. 224*61046927SAndroid Build Coastguard Worker 225*61046927SAndroid Build Coastguard WorkerThe tile size used depends on both the image size and the block size of the 226*61046927SAndroid Build Coastguard Workerimage format. For large images, :math:`n \times n` or :math:`2n \times n` tiles 227*61046927SAndroid Build Coastguard Workerare used (:math:`n` power-of-two). :math:`n` is such that each page contains 228*61046927SAndroid Build Coastguard Workerexactly one tile. Only power-of-two block sizes are supported in hardware, 229*61046927SAndroid Build Coastguard Workerensuring such a tile size always exists. The hardware uses 16 KiB pages, so tile 230*61046927SAndroid Build Coastguard Workersizes are as follows: 231*61046927SAndroid Build Coastguard Worker 232*61046927SAndroid Build Coastguard Worker.. list-table:: Tile sizes for large images 233*61046927SAndroid Build Coastguard Worker :widths: 50 50 234*61046927SAndroid Build Coastguard Worker :header-rows: 1 235*61046927SAndroid Build Coastguard Worker 236*61046927SAndroid Build Coastguard Worker * - Bytes per block 237*61046927SAndroid Build Coastguard Worker - Tile size 238*61046927SAndroid Build Coastguard Worker * - 1 239*61046927SAndroid Build Coastguard Worker - 128 x 128 240*61046927SAndroid Build Coastguard Worker * - 2 241*61046927SAndroid Build Coastguard Worker - 128 x 64 242*61046927SAndroid Build Coastguard Worker * - 4 243*61046927SAndroid Build Coastguard Worker - 64 x 64 244*61046927SAndroid Build Coastguard Worker * - 8 245*61046927SAndroid Build Coastguard Worker - 64 x 32 246*61046927SAndroid Build Coastguard Worker * - 16 247*61046927SAndroid Build Coastguard Worker - 32 x 32 248*61046927SAndroid Build Coastguard Worker 249*61046927SAndroid Build Coastguard WorkerThe dimensions of large images are rounded up to be multiples of the tile size. 250*61046927SAndroid Build Coastguard WorkerIn addition, non-power-of-two large images have extra padding tiles when 251*61046927SAndroid Build Coastguard Workermipmapping is used, see below. 252*61046927SAndroid Build Coastguard Worker 253*61046927SAndroid Build Coastguard WorkerThat rounding would waste a great deal of memory for small images. If 254*61046927SAndroid Build Coastguard Workeran image is smaller than this tile size, a smaller tile size is used to reduce 255*61046927SAndroid Build Coastguard Workerthe memory footprint. For small images, the tile size is :math:`m \times m` 256*61046927SAndroid Build Coastguard Workerwhere 257*61046927SAndroid Build Coastguard Worker 258*61046927SAndroid Build Coastguard Worker.. math:: 259*61046927SAndroid Build Coastguard Worker 260*61046927SAndroid Build Coastguard Worker m = 2^{\lceil \log_2( \min \{ \text{width}, \text{ height} \}) \rceil} 261*61046927SAndroid Build Coastguard Worker 262*61046927SAndroid Build Coastguard WorkerIn other words, small images use the smallest square power-of-two tile such that 263*61046927SAndroid Build Coastguard Workerthe image's minor axis fits in one tile. 264*61046927SAndroid Build Coastguard Worker 265*61046927SAndroid Build Coastguard WorkerFor mipmapped images, tile sizes are determined independently for each level. 266*61046927SAndroid Build Coastguard WorkerTypically, the first levels of an image are "large" and the remaining levels are 267*61046927SAndroid Build Coastguard Worker"small". This scheme reduces the memory footprint of mipmapping, compared to a 268*61046927SAndroid Build Coastguard Workerfixed tile size for the whole image. Each mip level are padded to fill at least 269*61046927SAndroid Build Coastguard Workerone cache line (128 bytes), ensure no cache line contains multiple mip levels. 270*61046927SAndroid Build Coastguard Worker 271*61046927SAndroid Build Coastguard WorkerThere is a wrinkle: the dimensions of large mip levels in tiles are determined 272*61046927SAndroid Build Coastguard Workerby the dimensions of level 0. For power-of-two images, the two calculations are 273*61046927SAndroid Build Coastguard Workerequivalent. However, they differ subtly for non-power-of-two images. To 274*61046927SAndroid Build Coastguard Workerdetermine the number of tiles to allocate for level :math:`l`, the number of 275*61046927SAndroid Build Coastguard Workertiles for level 0 should be right-shifted by :math:`2l`. That appears to divide 276*61046927SAndroid Build Coastguard Workerby :math:`2^l` in both width and height, matching the definition of mipmapping, 277*61046927SAndroid Build Coastguard Workerhowever it rounds down incorrectly. To compensate, the level contains one extra 278*61046927SAndroid Build Coastguard Workerrow, column, or both (with the corner) as required if any of the first :math:`l` 279*61046927SAndroid Build Coastguard Workerlevels were rounded down. This hurt the memory footprint. However, it means 280*61046927SAndroid Build Coastguard Workernon-power-of-two integer multiplication is only required for level 0. 281*61046927SAndroid Build Coastguard WorkerCalculating the sizes for subsequent levels requires only addition and bitwise 282*61046927SAndroid Build Coastguard Workermath. That simplifies the hardware (but complicates software). 283*61046927SAndroid Build Coastguard Worker 284*61046927SAndroid Build Coastguard WorkerA 2D image consists of a full miptree (constructed as above) rounded up to the 285*61046927SAndroid Build Coastguard Workerpage size (16 KiB). 286*61046927SAndroid Build Coastguard Worker 287*61046927SAndroid Build Coastguard Worker3D images consist simply of an array of 2D layers (constructed as above). That 288*61046927SAndroid Build Coastguard Workermeans cube maps, 2D arrays, cube map arrays, and 3D images all use the same 289*61046927SAndroid Build Coastguard Workerlayout. The only difference is the number of layers. Notably, 3D images (like 290*61046927SAndroid Build Coastguard Worker``GL_TEXTURE_3D``) reserve space even for mip levels that do not exist 291*61046927SAndroid Build Coastguard Workerlogically. These extra levels pad out layers of 3D images to the size of the 292*61046927SAndroid Build Coastguard Workerfirst layer, simplifying layout calculations for both software and hardware. 293*61046927SAndroid Build Coastguard WorkerAlthough the padding is logically unnecessary, it wastes little space compared 294*61046927SAndroid Build Coastguard Workerto the sizes of large mipmapped 3D textures. 295*61046927SAndroid Build Coastguard Worker 296*61046927SAndroid Build Coastguard Workerdrm-shim (Linux only) 297*61046927SAndroid Build Coastguard Worker--------------------- 298*61046927SAndroid Build Coastguard Worker 299*61046927SAndroid Build Coastguard WorkerMesa includes a library that mocks out the DRM UABI used by the Asahi driver 300*61046927SAndroid Build Coastguard Workerstack, allowing the Mesa driver to run on non-M1 Linux hardware. This can be 301*61046927SAndroid Build Coastguard Workeruseful for exercising the compiler. To build, use options: 302*61046927SAndroid Build Coastguard Worker 303*61046927SAndroid Build Coastguard Worker:: 304*61046927SAndroid Build Coastguard Worker 305*61046927SAndroid Build Coastguard Worker -Dgallium-drivers=asahi -Dtools=drm-shim 306*61046927SAndroid Build Coastguard Worker 307*61046927SAndroid Build Coastguard WorkerThen run an OpenGL workload with environment variable: 308*61046927SAndroid Build Coastguard Worker 309*61046927SAndroid Build Coastguard Worker.. code-block:: sh 310*61046927SAndroid Build Coastguard Worker 311*61046927SAndroid Build Coastguard Worker LD_PRELOAD=~/mesa/build/src/asahi/drm-shim/libasahi_noop_drm_shim.so 312*61046927SAndroid Build Coastguard Worker 313*61046927SAndroid Build Coastguard WorkerFor example to compile a shader with shaderdb and print some statistics along 314*61046927SAndroid Build Coastguard Workerwith the IR: 315*61046927SAndroid Build Coastguard Worker 316*61046927SAndroid Build Coastguard Worker.. code-block:: sh 317*61046927SAndroid Build Coastguard Worker 318*61046927SAndroid Build Coastguard Worker ~/shader-db$ AGX_MESA_DEBUG=shaders,shaderdb ASAHI_MESA_DEBUG=precompile LD_PRELOAD=~/mesa/build/src/asahi/drm-shim/libasahi_noop_drm_shim.so ./run shaders/glmark/1-12.shader_test 319*61046927SAndroid Build Coastguard Worker 320*61046927SAndroid Build Coastguard WorkerThe drm-shim implementation for Asahi is located in ``src/asahi/drm-shim``. The 321*61046927SAndroid Build Coastguard Workerdrm-shim implementation there should be updated as new UABI is added. 322*61046927SAndroid Build Coastguard Worker 323*61046927SAndroid Build Coastguard WorkerHardware glossary 324*61046927SAndroid Build Coastguard Worker----------------- 325*61046927SAndroid Build Coastguard Worker 326*61046927SAndroid Build Coastguard WorkerAGX is a tiled renderer descended from the PowerVR architecture. Some hardware 327*61046927SAndroid Build Coastguard Workerconcepts used in PowerVR GPUs appear in AGX. 328*61046927SAndroid Build Coastguard Worker 329*61046927SAndroid Build Coastguard Worker.. glossary:: :sorted: 330*61046927SAndroid Build Coastguard Worker 331*61046927SAndroid Build Coastguard Worker VDM 332*61046927SAndroid Build Coastguard Worker Vertex Data Master 333*61046927SAndroid Build Coastguard Worker Dispatches vertex shaders. 334*61046927SAndroid Build Coastguard Worker 335*61046927SAndroid Build Coastguard Worker PDM 336*61046927SAndroid Build Coastguard Worker Pixel Data Master 337*61046927SAndroid Build Coastguard Worker Dispatches pixel shaders. 338*61046927SAndroid Build Coastguard Worker 339*61046927SAndroid Build Coastguard Worker CDM 340*61046927SAndroid Build Coastguard Worker Compute Data Master 341*61046927SAndroid Build Coastguard Worker Dispatches compute kernels. 342*61046927SAndroid Build Coastguard Worker 343*61046927SAndroid Build Coastguard Worker USC 344*61046927SAndroid Build Coastguard Worker Unified Shader Cores 345*61046927SAndroid Build Coastguard Worker A unified shader core is a small CPU that runs shader code. The core is 346*61046927SAndroid Build Coastguard Worker unified because a single ISA is used for vertex, pixel and compute 347*61046927SAndroid Build Coastguard Worker shaders. This differs from older GPUs where the vertex, fragment and 348*61046927SAndroid Build Coastguard Worker compute have separate ISAs for shader stages. 349*61046927SAndroid Build Coastguard Worker 350*61046927SAndroid Build Coastguard Worker PPP 351*61046927SAndroid Build Coastguard Worker Primitive Processing Pipeline 352*61046927SAndroid Build Coastguard Worker The Primitive Processing Pipeline is a hardware unit that does primitive 353*61046927SAndroid Build Coastguard Worker assembly. The PPP is between the :term:`VDM` and :term:`ISP`. 354*61046927SAndroid Build Coastguard Worker 355*61046927SAndroid Build Coastguard Worker ISP 356*61046927SAndroid Build Coastguard Worker Image Synthesis Processor 357*61046927SAndroid Build Coastguard Worker The Image Synthesis Processor is responsible for the rasterization stage 358*61046927SAndroid Build Coastguard Worker of the rendering pipeline. 359*61046927SAndroid Build Coastguard Worker 360*61046927SAndroid Build Coastguard Worker PBE 361*61046927SAndroid Build Coastguard Worker Pixel BackEnd 362*61046927SAndroid Build Coastguard Worker Hardware unit which writes to color attachments and images. Also the 363*61046927SAndroid Build Coastguard Worker name for a descriptor passed to :term:`PBE` instructions. 364*61046927SAndroid Build Coastguard Worker 365*61046927SAndroid Build Coastguard Worker UVS 366*61046927SAndroid Build Coastguard Worker Unified Vertex Store 367*61046927SAndroid Build Coastguard Worker Hardware unit which buffers the outputs of the vertex shader (varyings). 368