Top |
#define | INTEL_BUF_INVALID_ADDRESS |
#define | INTEL_BUF_NAME_MAXSIZE |
struct | intel_buf |
struct | buf_ops |
Intel GPU devices supports different set of tiled surfaces. Checking each time what tile formats are supports is cumbersome and error prone.
Buffer operation (buf_ops) provide a wrapper to conditional code which can be used without worrying of implementation details giving:
copy linear to tiled buffer
copy tiled buffer to linear
Following code order should be used (linear is plain memory with some image data):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
struct buf_ops *bops; struct intel_buf ibuf; ... bops = buf_ops_create(fd); intel_buf_init(bops, &ibuf, 512, 512, 32, 64, I915_TILING_X, false); ... linear_to_intel_buf(bops, &ibuf, linear); ... intel_buf_to_linear(bops, &ibuf, linear); ... intel_buf_close(bops, &ibuf); ... buf_ops_destroy(bops); |
Calling buf_ops_create(fd) probes hardware capabilities (supported fences,
swizzling) and returns opaque pointer to buf_ops. From now on
intel_buf_to_linear()
and linear_to_intel_buf()
will choose appropriate
function to do the job.
Note: bufops doesn't support SW tiling code yet.
struct buf_ops *
buf_ops_create (int fd
);
Create buf_ops structure depending on fd-device capabilities.
struct buf_ops *
buf_ops_create_with_selftest (int fd
);
Create buf_ops structure depending on fd-device capabilities. Runs with idempotency selftest to verify software tiling gives same result like hardware tiling (gens with mappable gtt).
bool buf_ops_set_software_tiling (struct buf_ops *bops
,uint32_t tiling
,bool use_software_tiling
);
Function allows switch X / Y surfaces to software / hardware copying methods which honors tiling and swizzling.
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
);
Function checks if surface with tiling has HW fences which can be used to copy it via gtt.
bool buf_ops_has_tiling_support (struct buf_ops *bops
,uint32_t tiling
);
Function checks capabilities to handle surfaces with tiling in GPU.
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
);
Function creates new BO within intel_buf structure and fills all structure fields. Takes bo handle ownership.
Note. For X / Y if GPU supports fences HW tiling is configured.
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
);
Same as intel_buf_init with the additional region argument
void intel_buf_close (struct buf_ops *bops
,struct intel_buf *buf
);
Function closes gem BO inside intel_buf if bo is owned by intel_buf.
For handle passed from the caller intel_buf doesn't take ownership and
doesn't close it in close()
/destroy()
paths. When intel_buf was previously
added to intel_bb (intel_bb_add_intel_buf()
call) it is tracked there and
must be removed from its internal structures.
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
);
Function configures BO handle within intel_buf structure passed by the caller (with all its metadata - width, height, ...). Useful if BO was created outside. Allows passing real size which caller is aware of.
Note: intel_buf_close()
can be used because intel_buf is aware it is not
buffer owner so it won't close it underneath.
bops |
pointer to buf_ops |
|
handle |
BO handle created by the caller |
|
buf |
pointer to intel_buf structure to be filled |
|
width |
surface width |
|
height |
surface height |
|
bpp |
bits-per-pixel (8 / 16 / 32 / 64) |
|
alignment |
alignment of the stride for linear surfaces |
|
req_tiling |
surface tiling |
|
compression |
surface compression type |
|
size |
real bo size |
|
stride |
bo stride |
|
region |
region |
|
pat_index |
mocs_index to use for operations using this intel_buf, like render copy. |
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
);
Function creates intel_buf with created BO handle. Takes ownership of the buffer.
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
);
Function configures BO handle within intel_buf structure passed by the caller (with all its metadata - width, height, ...). Useful if BO was created outside.
Note: intel_buf_close()
can be used because intel_buf is aware it is not
buffer owner so it won't close it underneath.
bops |
pointer to buf_ops |
|
handle |
BO handle created by the caller |
|
buf |
pointer to intel_buf structure to be filled |
|
width |
surface width |
|
height |
surface height |
|
bpp |
bits-per-pixel (8 / 16 / 32 / 64) |
|
alignment |
alignment of the stride for linear surfaces |
|
tiling |
surface tiling |
|
compression |
surface compression type |
|
size |
real bo 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
);
Function creates intel_buf with passed BO handle from the caller. Doesn't
take ownership of the buffer. close()
/destroy()
paths doesn't close
passed handle unless buffer will take ownership using set_ownership()
.
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
);
Function frees intel_buf memory. It closes bo handle if intel_buf has buffer ownership.
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
,...
);
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]; };