| 1 |
/* |
| 2 |
* Copyright (C) 2019 Collabora, Ltd. |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef PAN_PROPS_H |
| 7 |
#define PAN_PROPS_H |
| 8 |
|
| 9 |
#include <stdbool.h> |
| 10 |
#include <stdint.h> |
| 11 |
|
| 12 |
#include "util/macros.h" |
| 13 |
|
| 14 |
#include "pan_model.h" |
| 15 |
|
| 16 |
struct pan_kmod_dev; |
| 17 |
struct pan_kmod_dev_props; |
| 18 |
struct pan_kmod_vm; |
| 19 |
|
| 20 |
#define ARM_VENDOR_ID 0x13B5 |
| 21 |
|
| 22 |
unsigned pan_query_l2_slices(const struct pan_kmod_dev_props *props); |
| 23 |
|
| 24 |
struct pan_tiler_features |
| 25 |
pan_query_tiler_features(const struct pan_kmod_dev_props *props); |
| 26 |
|
| 27 |
unsigned pan_query_thread_tls_alloc(const struct pan_kmod_dev_props *props); |
| 28 |
|
| 29 |
uint32_t pan_query_compressed_formats(const struct pan_kmod_dev_props *props); |
| 30 |
|
| 31 |
unsigned pan_query_core_count(const struct pan_kmod_dev_props *props, |
| 32 |
unsigned *core_id_range); |
| 33 |
|
| 34 |
bool pan_query_afbc(const struct pan_kmod_dev_props *props); |
| 35 |
|
| 36 |
bool pan_query_afrc(const struct pan_kmod_dev_props *props); |
| 37 |
|
| 38 |
unsigned pan_query_tib_size(const struct pan_model *model); |
| 39 |
|
| 40 |
unsigned pan_query_z_tib_size(const struct pan_model *model); |
| 41 |
|
| 42 |
static inline unsigned |
| 43 |
pan_query_optimal_tib_size(unsigned arch, const struct pan_model *model) |
| 44 |
{ |
| 45 |
unsigned tib_size = pan_query_tib_size(model); |
| 46 |
|
| 47 |
/* On V5, as well as V7 and later, we can disable pipelining to gain some |
| 48 |
* extra tib memory. |
| 49 |
*/ |
| 50 |
if (arch > 4 && arch != 6) |
| 51 |
return tib_size / 2; |
| 52 |
|
| 53 |
return tib_size; |
| 54 |
} |
| 55 |
|
| 56 |
static inline unsigned |
| 57 |
pan_query_optimal_z_tib_size(unsigned arch, const struct pan_model *model) |
| 58 |
{ |
| 59 |
unsigned tib_size = pan_query_z_tib_size(model); |
| 60 |
|
| 61 |
/* On V5, as well as V7 and later, we can disable pipelining to gain some |
| 62 |
* extra tib memory. |
| 63 |
*/ |
| 64 |
if (arch > 4 && arch != 6) |
| 65 |
return tib_size / 2; |
| 66 |
|
| 67 |
return tib_size; |
| 68 |
} |
| 69 |
|
| 70 |
uint64_t pan_clamp_to_usable_va_range(const struct pan_kmod_dev *dev, |
| 71 |
uint64_t va); |
| 72 |
|
| 73 |
uint64_t pan_choose_gpu_va_alignment(const struct pan_kmod_vm *vm, |
| 74 |
uint64_t size); |
| 75 |
|
| 76 |
unsigned pan_compute_max_thread_count(const struct pan_kmod_dev_props *props, |
| 77 |
unsigned work_reg_count); |
| 78 |
|
| 79 |
static inline unsigned |
| 80 |
pan_max_effective_tile_size(unsigned arch) |
| 81 |
{ |
| 82 |
if (arch >= 12) |
| 83 |
return 64 * 64; |
| 84 |
|
| 85 |
if (arch >= 10) |
| 86 |
return 32 * 32; |
| 87 |
|
| 88 |
return 16 * 16; |
| 89 |
} |
| 90 |
|
| 91 |
static inline unsigned |
| 92 |
pan_meta_tile_size(unsigned arch) |
| 93 |
{ |
| 94 |
if (arch >= 12) |
| 95 |
return 64; |
| 96 |
|
| 97 |
return 32; |
| 98 |
} |
| 99 |
|
| 100 |
static inline uint32_t |
| 101 |
pan_get_max_cbufs(unsigned arch, unsigned max_tib_size) |
| 102 |
{ |
| 103 |
if (arch < 5) |
| 104 |
return 1; |
| 105 |
|
| 106 |
const unsigned min_msaa = 4; /* Vulkan *requires* at least 4x MSAA support */ |
| 107 |
const unsigned max_cbuf_format = 4 * 4; /* R32G32B32A32 */ |
| 108 |
const unsigned min_tile_size = 4 * 4; |
| 109 |
|
| 110 |
unsigned max_cbufs = |
| 111 |
max_tib_size / (min_msaa * max_cbuf_format * min_tile_size); |
| 112 |
|
| 113 |
return MIN2(max_cbufs, 8); |
| 114 |
} |
| 115 |
|
| 116 |
static inline unsigned |
| 117 |
pan_get_max_msaa(unsigned arch, unsigned max_tib_size, unsigned max_cbuf_atts, |
| 118 |
unsigned format_size) |
| 119 |
{ |
| 120 |
if (arch < 5) |
| 121 |
return 8; |
| 122 |
|
| 123 |
assert(max_cbuf_atts > 0); |
| 124 |
assert(format_size > 0); |
| 125 |
|
| 126 |
const unsigned min_tile_size = 4 * 4; |
| 127 |
unsigned max_msaa = max_tib_size / (max_cbuf_atts * format_size * |
| 128 |
min_tile_size); |
| 129 |
return MIN2(max_msaa, 16); |
| 130 |
} |
| 131 |
|
| 132 |
#endif |