| 1 |
/* |
| 2 |
* Copyright (C) 2022 Collabora, Ltd. |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef __PAN_EARLYZS_H__ |
| 7 |
#define __PAN_EARLYZS_H__ |
| 8 |
|
| 9 |
#include <stdbool.h> |
| 10 |
|
| 11 |
#ifdef __cplusplus |
| 12 |
extern "C" { |
| 13 |
#endif |
| 14 |
|
| 15 |
/* Early-ZS pair. */ |
| 16 |
struct pan_earlyzs_state { |
| 17 |
/* Z/S test and update */ |
| 18 |
unsigned update : 2; |
| 19 |
|
| 20 |
/* Pixel kill */ |
| 21 |
unsigned kill : 2; |
| 22 |
|
| 23 |
/* True if the shader read-only ZS optimization should be enabled */ |
| 24 |
bool shader_readonly_zs : 1; |
| 25 |
|
| 26 |
/* So it fits in a byte */ |
| 27 |
unsigned padding : 3; |
| 28 |
}; |
| 29 |
|
| 30 |
/* ZS tilebuf read access */ |
| 31 |
enum pan_earlyzs_zs_tilebuf_read { |
| 32 |
/* The ZS tile buffer is not read */ |
| 33 |
PAN_EARLYZS_ZS_TILEBUF_NOT_READ = 0, |
| 34 |
|
| 35 |
/* The ZS tile buffer is read but the read-only optimization must be |
| 36 |
* disabled |
| 37 |
*/ |
| 38 |
PAN_EARLYZS_ZS_TILEBUF_READ_NO_OPT, |
| 39 |
|
| 40 |
/* The ZS tile buffer is read and the read-only optimization can be |
| 41 |
* enabled |
| 42 |
*/ |
| 43 |
PAN_EARLYZS_ZS_TILEBUF_READ_OPT, |
| 44 |
|
| 45 |
/* Number of ZS read modes */ |
| 46 |
PAN_EARLYZS_ZS_TILEBUF_MODE_COUNT, |
| 47 |
}; |
| 48 |
|
| 49 |
/* Internal lookup table. Users should treat as an opaque structure and only |
| 50 |
* access through pan_earlyzs_get and pan_earlyzs_analyze. See pan_earlyzs_get |
| 51 |
* for definition of the arrays. |
| 52 |
*/ |
| 53 |
struct pan_earlyzs_lut { |
| 54 |
struct pan_earlyzs_state states[2][2][2][PAN_EARLYZS_ZS_TILEBUF_MODE_COUNT]; |
| 55 |
}; |
| 56 |
|
| 57 |
/* |
| 58 |
* Look up early-ZS state. This is in the draw hot path on Valhall, so this is |
| 59 |
* defined inline in the header. |
| 60 |
*/ |
| 61 |
static inline struct pan_earlyzs_state |
| 62 |
pan_earlyzs_get(struct pan_earlyzs_lut lut, bool writes_zs_or_oq, |
| 63 |
bool alpha_to_coverage, bool zs_always_passes, |
| 64 |
enum pan_earlyzs_zs_tilebuf_read zs_read) |
| 65 |
{ |
| 66 |
return lut.states[writes_zs_or_oq][alpha_to_coverage][zs_always_passes] |
| 67 |
[zs_read]; |
| 68 |
} |
| 69 |
|
| 70 |
struct pan_shader_info; |
| 71 |
|
| 72 |
struct pan_earlyzs_lut pan_earlyzs_analyze(const struct pan_shader_info *s, |
| 73 |
unsigned arch); |
| 74 |
|
| 75 |
#ifdef __cplusplus |
| 76 |
} /* extern C */ |
| 77 |
#endif |
| 78 |
|
| 79 |
#endif |