17ec681f3Smrg/* 27ec681f3Smrg * Copyright (C) 2019 Collabora, Ltd. 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 217ec681f3Smrg * SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef __PANFROST_QUIRKS_H 257ec681f3Smrg#define __PANFROST_QUIRKS_H 267ec681f3Smrg 277ec681f3Smrg/* Model-specific quirks requiring workarounds/etc. Quirks may be errata 287ec681f3Smrg * requiring a workaround, or features. We're trying to be quirk-positive 297ec681f3Smrg * here; quirky is the best! */ 307ec681f3Smrg 317ec681f3Smrg/* Whether the GPU lacks the capability for hierarchical tiling, without an 327ec681f3Smrg * "Advanced Tiling Unit", instead requiring a single bin size for the entire 337ec681f3Smrg * framebuffer be selected by the driver */ 347ec681f3Smrg 357ec681f3Smrg#define MIDGARD_NO_HIER_TILING (1 << 0) 367ec681f3Smrg 377ec681f3Smrg/* Whether this GPU lacks native multiple render target support and accordingly 387ec681f3Smrg * needs SFBDs instead, with complex lowering with ES3 */ 397ec681f3Smrg 407ec681f3Smrg#define MIDGARD_SFBD (1 << 1) 417ec681f3Smrg 427ec681f3Smrg/* Whether fp16 is broken in the compiler. Hopefully this quirk will go away 437ec681f3Smrg * over time */ 447ec681f3Smrg 457ec681f3Smrg#define MIDGARD_BROKEN_FP16 (1 << 2) 467ec681f3Smrg 477ec681f3Smrg/* What it says on the tin */ 487ec681f3Smrg#define HAS_SWIZZLES (1 << 4) 497ec681f3Smrg 507ec681f3Smrg/* bit 5 unused */ 517ec681f3Smrg 527ec681f3Smrg/* Whether this GPU lacks support for any typed stores in blend shader, 537ec681f3Smrg * requiring packing instead */ 547ec681f3Smrg#define MIDGARD_NO_TYPED_BLEND_STORES (1 << 6) 557ec681f3Smrg 567ec681f3Smrg/* Whether this GPU lacks support for any typed loads, requiring packing */ 577ec681f3Smrg#define MIDGARD_NO_TYPED_BLEND_LOADS (1 << 7) 587ec681f3Smrg 597ec681f3Smrg/* Lack support for colour pack/unpack opcodes */ 607ec681f3Smrg#define NO_BLEND_PACKS (1 << 8) 617ec681f3Smrg 627ec681f3Smrg/* Has some missing formats for typed loads */ 637ec681f3Smrg#define MIDGARD_MISSING_LOADS (1 << 9) 647ec681f3Smrg 657ec681f3Smrg/* Lack support for AFBC */ 667ec681f3Smrg#define MIDGARD_NO_AFBC (1 << 10) 677ec681f3Smrg 687ec681f3Smrg/* Does this GPU support anisotropic filtering? */ 697ec681f3Smrg#define HAS_ANISOTROPIC (1 << 11) 707ec681f3Smrg 717ec681f3Smrg#define NO_TILE_ENABLE_MAP (1 << 12) 727ec681f3Smrg 737ec681f3Smrg/* Quirk collections common to particular uarchs */ 747ec681f3Smrg 757ec681f3Smrg#define MIDGARD_QUIRKS (MIDGARD_BROKEN_FP16 | HAS_SWIZZLES \ 767ec681f3Smrg | MIDGARD_NO_TYPED_BLEND_STORES \ 777ec681f3Smrg | MIDGARD_MISSING_LOADS) 787ec681f3Smrg 797ec681f3Smrg#define BIFROST_QUIRKS NO_BLEND_PACKS 807ec681f3Smrg 817ec681f3Smrgstatic inline unsigned 827ec681f3Smrgpanfrost_get_quirks(unsigned gpu_id, unsigned gpu_revision) 837ec681f3Smrg{ 847ec681f3Smrg switch (gpu_id) { 857ec681f3Smrg case 0x600: 867ec681f3Smrg case 0x620: 877ec681f3Smrg return MIDGARD_QUIRKS | MIDGARD_SFBD 887ec681f3Smrg | MIDGARD_NO_TYPED_BLEND_LOADS 897ec681f3Smrg | NO_BLEND_PACKS | MIDGARD_NO_AFBC 907ec681f3Smrg | NO_TILE_ENABLE_MAP; 917ec681f3Smrg 927ec681f3Smrg case 0x720: 937ec681f3Smrg return MIDGARD_QUIRKS | MIDGARD_SFBD | MIDGARD_NO_HIER_TILING 947ec681f3Smrg | MIDGARD_NO_AFBC | NO_TILE_ENABLE_MAP; 957ec681f3Smrg 967ec681f3Smrg case 0x820: 977ec681f3Smrg case 0x830: 987ec681f3Smrg return MIDGARD_QUIRKS | MIDGARD_NO_HIER_TILING; 997ec681f3Smrg 1007ec681f3Smrg case 0x750: 1017ec681f3Smrg return MIDGARD_QUIRKS; 1027ec681f3Smrg 1037ec681f3Smrg case 0x860: 1047ec681f3Smrg case 0x880: 1057ec681f3Smrg return MIDGARD_QUIRKS; 1067ec681f3Smrg 1077ec681f3Smrg case 0x6000: /* G71 */ 1087ec681f3Smrg return BIFROST_QUIRKS | HAS_SWIZZLES; 1097ec681f3Smrg 1107ec681f3Smrg case 0x6221: /* G72 */ 1117ec681f3Smrg /* Anisotropic filtering is supported from r0p3 onwards */ 1127ec681f3Smrg return BIFROST_QUIRKS | HAS_SWIZZLES 1137ec681f3Smrg | (gpu_revision >= 0x30 ? HAS_ANISOTROPIC : 0); 1147ec681f3Smrg 1157ec681f3Smrg case 0x7093: /* G31 */ 1167ec681f3Smrg case 0x7212: /* G52 */ 1177ec681f3Smrg case 0x7402: /* G52r1 */ 1187ec681f3Smrg return BIFROST_QUIRKS | HAS_ANISOTROPIC; 1197ec681f3Smrg 1207ec681f3Smrg default: 1217ec681f3Smrg unreachable("Unknown Panfrost GPU ID"); 1227ec681f3Smrg } 1237ec681f3Smrg} 1247ec681f3Smrg 1257ec681f3Smrg#endif 126