| 1 |
/* |
| 2 |
* Copyright (C) 2019 Collabora, Ltd. |
| 3 |
* Copyright (C) 2026 Arm Ltd. |
| 4 |
* SPDX-License-Identifier: MIT |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef PAN_MODEL_H |
| 8 |
#define PAN_MODEL_H |
| 9 |
|
| 10 |
#include <stdbool.h> |
| 11 |
#include <stdint.h> |
| 12 |
|
| 13 |
#include "util/macros.h" |
| 14 |
|
| 15 |
/** Implementation-defined tiler features */ |
| 16 |
struct pan_tiler_features { |
| 17 |
/** Number of bytes per tiler bin */ |
| 18 |
unsigned bin_size; |
| 19 |
|
| 20 |
/** Maximum number of levels that may be simultaneously enabled. |
| 21 |
* Invariant: bitcount(hierarchy_mask) <= max_levels */ |
| 22 |
unsigned max_levels; |
| 23 |
}; |
| 24 |
|
| 25 |
#define PAN_ARCH_MAJOR(x) (((x) & BITFIELD_RANGE(28, 4)) >> 28) |
| 26 |
#define PAN_ARCH_MINOR(x) (((x) & BITFIELD_RANGE(24, 4)) >> 24) |
| 27 |
#define PAN_ARCH_REV(x) (((x) & BITFIELD_RANGE(20, 4)) >> 20) |
| 28 |
#define PAN_PRODUCT_MAJOR(x) (((x) & BITFIELD_RANGE(16, 4)) >> 16) |
| 29 |
|
| 30 |
#define PAN_VERSION_MAJOR(x) (((x) & BITFIELD_RANGE(12, 4)) >> 12) |
| 31 |
#define PAN_VERSION_MINOR(x) (((x) & BITFIELD_RANGE(4, 8)) >> 4) |
| 32 |
#define PAN_VERSION_STATUS(x) ((x) & BITFIELD_RANGE(0, 4)) |
| 33 |
|
| 34 |
/* GPU product id for Midgard */ |
| 35 |
#define MIDGARD_PROD_ID(x) (((x) & BITFIELD_RANGE(16, 16)) >> 16) |
| 36 |
|
| 37 |
/* GPU product id since Bifrost. Assume 8 bits per field which ensures the |
| 38 |
* prod_id is always greater than Midgard's. */ |
| 39 |
#define PAN_PROD_ID(arch_major, arch_minor, prod_major) \ |
| 40 |
(((arch_major) << 16) | ((arch_minor) << 8) | (prod_major)) |
| 41 |
|
| 42 |
/* GPU revision (rXpY) */ |
| 43 |
#define PAN_REV(ver_major, ver_minor) (((ver_major) << 8) | ((ver_minor))) |
| 44 |
|
| 45 |
struct pan_model { |
| 46 |
/* GPU product ID */ |
| 47 |
uint32_t gpu_prod_id; |
| 48 |
|
| 49 |
/* GPU variant. */ |
| 50 |
uint32_t gpu_variant; |
| 51 |
|
| 52 |
/* Marketing name for the GPU, used as the GL_RENDERER */ |
| 53 |
const char *name; |
| 54 |
|
| 55 |
/* Set of associated performance counters */ |
| 56 |
const char *performance_counters; |
| 57 |
|
| 58 |
/* Minimum GPU revision required for anisotropic filtering. ~0 and 0 |
| 59 |
* means "no revisions support anisotropy" and "all revisions support |
| 60 |
* anistropy" respectively -- so checking for anisotropy is simply |
| 61 |
* comparing the reivsion. |
| 62 |
*/ |
| 63 |
uint32_t min_rev_anisotropic; |
| 64 |
|
| 65 |
struct { |
| 66 |
/* Default tilebuffer size in bytes for the model. */ |
| 67 |
uint32_t color_size; |
| 68 |
|
| 69 |
/* Default tilebuffer depth size in bytes for the model. */ |
| 70 |
uint32_t z_size; |
| 71 |
} tilebuffer; |
| 72 |
|
| 73 |
/* Maximum number of pixels, texels, and FMA ops, per clock per shader |
| 74 |
* core, or 0 if it can't be determined for the given GPU. */ |
| 75 |
struct { |
| 76 |
uint32_t pixel; |
| 77 |
uint32_t texel; |
| 78 |
uint32_t fma; |
| 79 |
} rates; |
| 80 |
|
| 81 |
struct { |
| 82 |
/* The GPU lacks the capability for hierarchical tiling, without |
| 83 |
* an "Advanced Tiling Unit", instead requiring a single bin |
| 84 |
* size for the entire framebuffer be selected by the driver |
| 85 |
*/ |
| 86 |
bool no_hierarchical_tiling; |
| 87 |
bool max_4x_msaa; |
| 88 |
} quirks; |
| 89 |
}; |
| 90 |
|
| 91 |
const struct pan_model *pan_get_model(uint64_t gpu_id, uint32_t gpu_variant); |
| 92 |
|
| 93 |
/* Returns the architecture version given a GPU ID, either from a table for |
| 94 |
* old-style Midgard versions or directly for new-style Bifrost/Valhall |
| 95 |
* versions */ |
| 96 |
|
| 97 |
static inline unsigned |
| 98 |
pan_arch(uint64_t gpu_id) |
| 99 |
{ |
| 100 |
switch (MIDGARD_PROD_ID(gpu_id)) { |
| 101 |
case 0x600: |
| 102 |
case 0x620: |
| 103 |
case 0x720: |
| 104 |
return 4; |
| 105 |
case 0x750: |
| 106 |
case 0x820: |
| 107 |
case 0x830: |
| 108 |
case 0x860: |
| 109 |
case 0x880: |
| 110 |
return 5; |
| 111 |
default: |
| 112 |
return PAN_ARCH_MAJOR(gpu_id); |
| 113 |
} |
| 114 |
} |
| 115 |
|
| 116 |
static inline uint32_t |
| 117 |
pan_prod_id(uint64_t gpu_id) |
| 118 |
{ |
| 119 |
unsigned arch = pan_arch(gpu_id); |
| 120 |
if (arch < 6) |
| 121 |
return MIDGARD_PROD_ID(gpu_id); |
| 122 |
return PAN_PROD_ID(PAN_ARCH_MAJOR(gpu_id), PAN_ARCH_MINOR(gpu_id), |
| 123 |
PAN_PRODUCT_MAJOR(gpu_id)); |
| 124 |
} |
| 125 |
|
| 126 |
static inline uint32_t |
| 127 |
pan_rev(uint64_t gpu_id) |
| 128 |
{ |
| 129 |
return PAN_REV(PAN_VERSION_MAJOR(gpu_id), PAN_VERSION_MINOR(gpu_id)); |
| 130 |
} |
| 131 |
|
| 132 |
#endif |