| 1 |
/* |
| 2 |
* Copyright (C) 2025 Collabora, Ltd. |
| 3 |
* SPDX-License-Identifier: MIT |
| 4 |
*/ |
| 5 |
|
| 6 |
#ifndef __PAN_MOD_H |
| 7 |
#define __PAN_MOD_H |
| 8 |
|
| 9 |
#ifdef __cplusplus |
| 10 |
extern "C" { |
| 11 |
#endif |
| 12 |
|
| 13 |
#include "util/format/u_format.h" |
| 14 |
|
| 15 |
#include "pan_layout.h" |
| 16 |
|
| 17 |
struct pan_attachment_info; |
| 18 |
struct pan_image; |
| 19 |
struct pan_image_view; |
| 20 |
struct pan_image_usage; |
| 21 |
struct pan_kmod_dev_props; |
| 22 |
struct pan_mod_handler; |
| 23 |
|
| 24 |
enum pan_mod_support { |
| 25 |
PAN_MOD_NOT_SUPPORTED = 0, |
| 26 |
PAN_MOD_NOT_OPTIMAL, |
| 27 |
PAN_MOD_OPTIMAL, |
| 28 |
}; |
| 29 |
|
| 30 |
struct pan_mod_handler { |
| 31 |
bool (*match)(uint64_t mod); |
| 32 |
|
| 33 |
/* Used to check if a set of image properties is valid. Passing a NULL iusage |
| 34 |
* is valid and means "optimal set of usage for this mod". This implies |
| 35 |
* that some non-supported cases can't be detected or can be reported as |
| 36 |
* optimal when specific usage flags would report it non-optimal. |
| 37 |
*/ |
| 38 |
enum pan_mod_support (*test_props)(const struct pan_kmod_dev_props *dprops, |
| 39 |
const struct pan_image_props *iprops, |
| 40 |
const struct pan_image_usage *iusage); |
| 41 |
|
| 42 |
/* Optional method used to initialize modifier-specific per-plane layout |
| 43 |
* data. This is called before init_slice_layout(). |
| 44 |
*/ |
| 45 |
bool (*init_plane_layout)(const struct pan_image_props *props, |
| 46 |
unsigned plane_idx, |
| 47 |
struct pan_image_layout *plane_layout); |
| 48 |
|
| 49 |
bool (*init_slice_layout)( |
| 50 |
const struct pan_image_props *props, unsigned plane_idx, |
| 51 |
struct pan_image_extent mip_extent_px, |
| 52 |
const struct pan_image_layout_constraints *layout_constraints, |
| 53 |
struct pan_image_slice_layout *slice); |
| 54 |
uint32_t (*get_wsi_row_pitch)(const struct pan_image *image, |
| 55 |
unsigned plane_idx, unsigned mip_level); |
| 56 |
|
| 57 |
void (*emit_tex_payload_entry)(const struct pan_image_view *iview, |
| 58 |
unsigned mip_level, unsigned layer_or_z_slice, |
| 59 |
unsigned sample, void **payload); |
| 60 |
|
| 61 |
void (*emit_color_attachment)(const struct pan_attachment_info *att, |
| 62 |
void *payload); |
| 63 |
void (*emit_zs_attachment)(const struct pan_attachment_info *att, |
| 64 |
void *payload); |
| 65 |
void (*emit_s_attachment)(const struct pan_attachment_info *att, |
| 66 |
void *payload); |
| 67 |
}; |
| 68 |
|
| 69 |
#ifdef PAN_ARCH |
| 70 |
const struct pan_mod_handler *GENX(pan_mod_get_handler)(uint64_t modifier); |
| 71 |
|
| 72 |
static inline const struct pan_mod_handler * |
| 73 |
pan_mod_get_handler(unsigned arch, uint64_t modifier) |
| 74 |
{ |
| 75 |
assert(arch == PAN_ARCH); |
| 76 |
return GENX(pan_mod_get_handler)(modifier); |
| 77 |
} |
| 78 |
#else |
| 79 |
const struct pan_mod_handler *pan_mod_get_handler_v4(uint64_t modifier); |
| 80 |
const struct pan_mod_handler *pan_mod_get_handler_v5(uint64_t modifier); |
| 81 |
const struct pan_mod_handler *pan_mod_get_handler_v6(uint64_t modifier); |
| 82 |
const struct pan_mod_handler *pan_mod_get_handler_v7(uint64_t modifier); |
| 83 |
const struct pan_mod_handler *pan_mod_get_handler_v9(uint64_t modifier); |
| 84 |
const struct pan_mod_handler *pan_mod_get_handler_v10(uint64_t modifier); |
| 85 |
const struct pan_mod_handler *pan_mod_get_handler_v12(uint64_t modifier); |
| 86 |
const struct pan_mod_handler *pan_mod_get_handler_v13(uint64_t modifier); |
| 87 |
|
| 88 |
static inline const struct pan_mod_handler * |
| 89 |
pan_mod_get_handler(unsigned arch, uint64_t modifier) |
| 90 |
{ |
| 91 |
switch (arch) { |
| 92 |
case 4: |
| 93 |
return pan_mod_get_handler_v4(modifier); |
| 94 |
case 5: |
| 95 |
return pan_mod_get_handler_v5(modifier); |
| 96 |
case 6: |
| 97 |
return pan_mod_get_handler_v6(modifier); |
| 98 |
case 7: |
| 99 |
return pan_mod_get_handler_v7(modifier); |
| 100 |
case 9: |
| 101 |
return pan_mod_get_handler_v9(modifier); |
| 102 |
case 10: |
| 103 |
return pan_mod_get_handler_v10(modifier); |
| 104 |
case 12: |
| 105 |
return pan_mod_get_handler_v12(modifier); |
| 106 |
case 13: |
| 107 |
return pan_mod_get_handler_v13(modifier); |
| 108 |
default: |
| 109 |
UNREACHABLE("Unsupported arch"); |
| 110 |
} |
| 111 |
} |
| 112 |
#endif |
| 113 |
|
| 114 |
#ifdef __cplusplus |
| 115 |
} /* extern C */ |
| 116 |
#endif |
| 117 |
|
| 118 |
#endif |