Buffer operations

Buffer operations — Buffer operation on tiled surfaces

Functions

Types and Values

struct intel_buf
struct buf_ops

Includes

#include <igt.h>

Description

Buffer operations

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, 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.

Functions

intel_buf_aux_width ()

unsigned int
intel_buf_aux_width (int gen,
                     const struct intel_buf *buf);

intel_buf_aux_height ()

unsigned int
intel_buf_aux_height (int gen,
                      const struct intel_buf *buf);

buf_ops_create ()

struct buf_ops *
buf_ops_create (int fd);

Create buf_ops structure depending on fd-device capabilities.

Parameters

fd

device filedescriptor

 

Returns

opaque pointer to buf_ops.


buf_ops_destroy ()

void
buf_ops_destroy (struct buf_ops *bops);

Function frees buf_ops structure.

Parameters

bops

pointer to buf_ops

 

buf_ops_set_software_tiling ()

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.

Parameters

bops

pointer to buf_ops

 

tiling

surface tiling

 

use_software_tiling

if true use software copying methods, otherwise use hardware (via gtt)

 

Returns

false - switch wasn't possible. true - switch to software / hardware method succeed.


intel_buf_to_linear ()

void
intel_buf_to_linear (struct buf_ops *bops,
                     struct intel_buf *buf,
                     uint32_t *linear);

linear_to_intel_buf ()

void
linear_to_intel_buf (struct buf_ops *bops,
                     struct intel_buf *buf,
                     uint32_t *linear);

buf_ops_has_hw_fence ()

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.

Parameters

bops

pointer to buf_ops

 

tiling

surface tiling

 

Returns

false - fence for tiling is not supported. true - fence for tiling is supported.


buf_ops_has_tiling_support ()

bool
buf_ops_has_tiling_support (struct buf_ops *bops,
                            uint32_t tiling);

Function checks capabilities to handle surfaces with tiling in GPU.

Parameters

bops

pointer to buf_ops

 

tiling

surface tiling

 

Returns

false - GPU does not support tiling. true - GPU supports tiling.


intel_buf_init ()

void
intel_buf_init (struct buf_ops *bops,
                struct intel_buf *buf,
                int width,
                int height,
                int bpp,
                uint32_t tiling,
                uint32_t compression);

Function creates new BO within intel_buf structure and fills all structure fields.

Note. For X / Y if GPU supports fences HW tiling is configured.

Parameters

bops

pointer to buf_ops

 

buf

pointer to intel_buf structure to be filled

 

width

surface width

 

height

surface height

 

bpp

bits-per-pixel (8 / 16 / 32)

 

tiling

surface tiling

 

compression

surface compression type

 

intel_buf_close ()

void
intel_buf_close (struct buf_ops *bops,
                 struct intel_buf *buf);

Function closes gem BO inside intel_buf.

Parameters

bops

pointer to buf_ops

 

buf

pointer to intel_buf structure

 

intel_buf_init_using_handle ()

void
intel_buf_init_using_handle (struct buf_ops *bops,
                             uint32_t handle,
                             struct intel_buf *buf,
                             int width,
                             int height,
                             int bpp,
                             uint32_t req_tiling,
                             uint32_t compression);

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 to close the BO handle, but caller must be aware to not close the BO twice.

Parameters

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)

 

tiling

surface tiling

 

compression

surface compression type

 

Types and Values

struct intel_buf

struct intel_buf {
	uint32_t handle;
	uint32_t stride;
	uint32_t tiling;
	uint32_t bpp;
	uint32_t size;
	uint32_t compression;
	struct {
		uint32_t offset;
		uint32_t stride;
	} aux;
};

struct buf_ops

struct buf_ops;