mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-19 05:46:25 +00:00
lib/igt_fb: igt_create_fb_with_bo_size
Useful for testing bigger/smaller fb-wrapped buffer objects. Cc: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Oscar Mateo <oscar.mateo@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
This commit is contained in:
parent
ace8a9e10c
commit
5bdd4d9b5e
45
lib/igt_fb.c
45
lib/igt_fb.c
@ -76,7 +76,8 @@ static struct format_desc_struct {
|
||||
/* helpers to create nice-looking framebuffers */
|
||||
static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
||||
bool tiled, uint32_t *gem_handle_ret,
|
||||
unsigned *size_ret, unsigned *stride_ret)
|
||||
unsigned *size_ret, unsigned *stride_ret,
|
||||
unsigned bo_size)
|
||||
{
|
||||
uint32_t gem_handle;
|
||||
int size, ret = 0;
|
||||
@ -106,7 +107,9 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
||||
size = stride * height;
|
||||
}
|
||||
|
||||
gem_handle = gem_create(fd, size);
|
||||
if (bo_size == 0)
|
||||
bo_size = size;
|
||||
gem_handle = gem_create(fd, bo_size);
|
||||
|
||||
if (tiled)
|
||||
ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride);
|
||||
@ -376,17 +379,18 @@ void igt_paint_image(cairo_t *cr, const char *filename,
|
||||
}
|
||||
|
||||
/**
|
||||
* igt_create_fb:
|
||||
* igt_create_fb_with_bo_size:
|
||||
* @fd: open i915 drm file descriptor
|
||||
* @width: width of the framebuffer in pixel
|
||||
* @height: height of the framebuffer in pixel
|
||||
* @format: drm fourcc pixel format code
|
||||
* @tiled: X-tiled or linear framebuffer
|
||||
* @fb: pointer to an #igt_fb structure
|
||||
* @bo_size: size of the backing bo (0 for minimum needed size)
|
||||
*
|
||||
* This function allocates a gem buffer object suitable to back a framebuffer
|
||||
* with the requested properties and then wraps it up in a drm framebuffer
|
||||
* object. All metadata is stored in @fb.
|
||||
* object of the requested size. All metadata is stored in @fb.
|
||||
*
|
||||
* The backing storage of the framebuffer is filled with all zeros, i.e. black
|
||||
* for rgb pixel formats.
|
||||
@ -395,8 +399,9 @@ void igt_paint_image(cairo_t *cr, const char *filename,
|
||||
* The kms id of the created framebuffer on success or a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||
bool tiled, struct igt_fb *fb)
|
||||
unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||
uint32_t format, bool tiled,
|
||||
struct igt_fb *fb, unsigned bo_size)
|
||||
{
|
||||
uint32_t handles[4];
|
||||
uint32_t pitches[4];
|
||||
@ -409,7 +414,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||
|
||||
bpp = igt_drm_format_to_bpp(format);
|
||||
ret = create_bo_for_fb(fd, width, height, bpp, tiled, &fb->gem_handle,
|
||||
&fb->size, &fb->stride);
|
||||
&fb->size, &fb->stride, bo_size);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@ -434,6 +439,32 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||
return fb_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* igt_create_fb:
|
||||
* @fd: open i915 drm file descriptor
|
||||
* @width: width of the framebuffer in pixel
|
||||
* @height: height of the framebuffer in pixel
|
||||
* @format: drm fourcc pixel format code
|
||||
* @tiled: X-tiled or linear framebuffer
|
||||
* @fb: pointer to an #igt_fb structure
|
||||
*
|
||||
* This function allocates a gem buffer object suitable to back a framebuffer
|
||||
* with the requested properties and then wraps it up in a drm framebuffer
|
||||
* object. All metadata is stored in @fb.
|
||||
*
|
||||
* The backing storage of the framebuffer is filled with all zeros, i.e. black
|
||||
* for rgb pixel formats.
|
||||
*
|
||||
* Returns:
|
||||
* The kms id of the created framebuffer on success or a negative error code on
|
||||
* failure.
|
||||
*/
|
||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||
bool tiled, struct igt_fb *fb)
|
||||
{
|
||||
return igt_create_fb_with_bo_size(fd, width, height, format, tiled, fb, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* igt_create_color_fb:
|
||||
* @fd: open i915 drm file descriptor
|
||||
|
@ -62,6 +62,9 @@ enum igt_text_align {
|
||||
align_hcenter = 0x08,
|
||||
};
|
||||
|
||||
unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||
uint32_t format, bool tiled,
|
||||
struct igt_fb *fb, unsigned bo_size);
|
||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||
bool tiled, struct igt_fb *fb);
|
||||
unsigned int igt_create_color_fb(int fd, int width, int height,
|
||||
|
Loading…
x
Reference in New Issue
Block a user