1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
|
#ifndef __INTEL_BUFOPS_H__
#define __INTEL_BUFOPS_H__
#include <stdint.h>
#include "igt_list.h"
#include "igt_aux.h"
#include "intel_batchbuffer.h"
struct buf_ops;
#define INTEL_BUF_INVALID_ADDRESS (-1ull)
#define INTEL_BUF_NAME_MAXSIZE 32
#define INVALID_ADDR(x) ((x) == INTEL_BUF_INVALID_ADDRESS)
struct intel_buf {
struct buf_ops *bops;
bool is_owner;
uint32_t handle;
uint64_t size;
uint32_t width;
uint32_t height;
uint32_t tiling;
uint32_t bpp, depth;
uint32_t compression;
uint32_t swizzle_mode;
uint32_t yuv_semiplanar_bpp;
bool format_is_yuv;
bool format_is_yuv_semiplanar;
struct {
uint32_t offset;
uint32_t stride;
uint64_t size;
} surface[2];
struct {
uint32_t offset;
uint32_t stride;
} ccs[2];
struct {
uint32_t offset;
bool disable;
} cc;
struct {
uint64_t offset;
uint32_t ctx;
} addr;
uint64_t bo_size;
uint64_t region;
/* Tracking */
struct intel_bb *ibb;
struct igt_list_head link;
/* CPU mapping */
uint32_t *ptr;
bool cpu_write;
/* Content Protection*/
bool is_protected;
/* pat_index to use for mapping this buf. Only used in Xe. */
uint8_t pat_index;
/* mocs_index to use for operations using this intel_buf, like render_copy */
uint8_t mocs_index;
/* For debugging purposes */
char name[INTEL_BUF_NAME_MAXSIZE + 1];
};
static inline bool intel_buf_compressed(const struct intel_buf *buf)
{
return buf->compression != I915_COMPRESSION_NONE;
}
static inline unsigned int intel_buf_width(const struct intel_buf *buf)
{
return buf->width;
}
static inline unsigned int intel_buf_height(const struct intel_buf *buf)
{
return buf->height;
}
static inline unsigned int
intel_buf_ccs_width(int gen, const struct intel_buf *buf)
{
/*
* GEN12+: The AUX CCS unit size is 64 bytes mapping 4 main surface
* tiles. Thus the width of the CCS unit is 4*32=128 pixels on the
* main surface.
*/
if (gen >= 12)
return DIV_ROUND_UP(intel_buf_width(buf), 512 / (buf->bpp / 8)) * 64;
return DIV_ROUND_UP(intel_buf_width(buf), 1024) * 128;
}
static inline unsigned int
intel_buf_ccs_height(int gen, const struct intel_buf *buf)
{
/*
* GEN12+: The AUX CCS unit size is 64 bytes mapping 4 main surface
* tiles. Thus the height of the CCS unit is 32 pixel rows on the main
* surface.
*/
if (gen >= 12)
return DIV_ROUND_UP(intel_buf_height(buf), 32);
return DIV_ROUND_UP(intel_buf_height(buf), 512) * 32;
}
uint64_t intel_buf_size(const struct intel_buf *buf);
uint64_t intel_buf_bo_size(const struct intel_buf *buf);
struct buf_ops *buf_ops_create(int fd);
struct buf_ops *buf_ops_create_with_selftest(int fd);
void buf_ops_destroy(struct buf_ops *bops);
int buf_ops_get_fd(struct buf_ops *bops);
uint32_t buf_ops_get_devid(struct buf_ops *bops);
enum intel_driver buf_ops_get_driver(struct buf_ops *bops);
bool buf_ops_set_software_tiling(struct buf_ops *bops,
uint32_t tiling,
bool use_software_tiling);
void intel_buf_to_linear(struct buf_ops *bops, struct intel_buf *buf,
uint32_t *linear);
void linear_to_intel_buf(struct buf_ops *bops, struct intel_buf *buf,
uint32_t *linear);
bool buf_ops_has_hw_fence(struct buf_ops *bops, uint32_t tiling);
bool buf_ops_has_tiling_support(struct buf_ops *bops, uint32_t tiling);
static inline void intel_buf_set_ownership(struct intel_buf *buf, bool is_owner)
{
buf->is_owner = is_owner;
}
void intel_buf_init(struct buf_ops *bops, struct intel_buf *buf,
int width, int height, int bpp, int alignment,
uint32_t tiling, uint32_t compression);
void intel_buf_init_in_region(struct buf_ops *bops,
struct intel_buf *buf,
int width, int height, int bpp, int alignment,
uint32_t tiling, uint32_t compression,
uint64_t region);
void intel_buf_close(struct buf_ops *bops, struct intel_buf *buf);
void intel_buf_init_full(struct buf_ops *bops,
uint32_t handle,
struct intel_buf *buf,
int width, int height,
int bpp, int alignment,
uint32_t req_tiling,
uint32_t compression,
uint64_t size,
int stride,
uint64_t region,
uint8_t pat_index,
uint8_t mocs_index);
struct intel_buf *intel_buf_create(struct buf_ops *bops,
int width, int height,
int bpp, int alignment,
uint32_t req_tiling, uint32_t compression);
void intel_buf_init_using_handle_and_size(struct buf_ops *bops,
uint32_t handle,
struct intel_buf *buf,
int width, int height,
int bpp, int alignment,
uint32_t req_tiling,
uint32_t compression,
uint64_t size);
struct intel_buf *intel_buf_create_using_handle_and_size(struct buf_ops *bops,
uint32_t handle,
int width, int height,
int bpp, int alignment,
uint32_t req_tiling,
uint32_t compression,
uint64_t size);
struct intel_buf *intel_buf_create_full(struct buf_ops *bops,
uint32_t handle,
int width, int height,
int bpp, int alignment,
uint32_t req_tiling,
uint32_t compression,
uint64_t size,
int stride,
uint64_t region,
uint8_t pat_index,
uint8_t mocs_index);
void intel_buf_destroy(struct intel_buf *buf);
static inline void intel_buf_set_pxp(struct intel_buf *buf, bool new_pxp_state)
{
igt_assert(buf);
buf->is_protected = new_pxp_state;
}
static inline bool intel_buf_pxp(const struct intel_buf *buf)
{
igt_assert(buf);
return buf->is_protected;
}
void *intel_buf_cpu_map(struct intel_buf *buf, bool write);
void *intel_buf_device_map(struct intel_buf *buf, bool write);
void intel_buf_unmap(struct intel_buf *buf);
void intel_buf_flush_and_unmap(struct intel_buf *buf);
void intel_buf_print(const struct intel_buf *buf);
void intel_buf_dump(const struct intel_buf *buf, const char *filename);
const char *intel_buf_set_name(struct intel_buf *buf, const char *name);
void intel_buf_write_to_png(struct intel_buf *buf, const char *filename);
void intel_buf_write_aux_to_png(struct intel_buf *buf, const char *filename);
void intel_buf_raw_write_to_png(struct intel_buf *buf, const char *namefmt, ...);
void intel_buf_draw_pattern(struct buf_ops *bops, struct intel_buf *buf,
int x, int y, int w, int h,
int cx, int cy, int cw, int ch,
bool use_alternate_colors);
#endif
|