mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-21 14:56:18 +00:00
lib: Change the fb creation functions to take fully qualified tiling formats
In the future, we'll need more than X tiling here. So give a full enum instead of bool meaning X-tiled. It's fine to do this change without updating the users just yet as 'true' happens to be I915_TILING_X. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
This commit is contained in:
parent
4d2f511cee
commit
378e61e4d8
37
lib/igt_fb.c
37
lib/igt_fb.c
@ -75,15 +75,15 @@ static struct format_desc_struct {
|
|||||||
|
|
||||||
/* helpers to create nice-looking framebuffers */
|
/* helpers to create nice-looking framebuffers */
|
||||||
static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
||||||
bool tiled, uint32_t *gem_handle_ret,
|
unsigned int tiling, uint32_t *gem_handle_ret,
|
||||||
unsigned *size_ret, unsigned *stride_ret,
|
unsigned *size_ret, unsigned *stride_ret, unsigned
|
||||||
unsigned bo_size)
|
bo_size)
|
||||||
{
|
{
|
||||||
uint32_t gem_handle;
|
uint32_t gem_handle;
|
||||||
int size, ret = 0;
|
int size, ret = 0;
|
||||||
unsigned stride;
|
unsigned stride;
|
||||||
|
|
||||||
if (tiled) {
|
if (tiling) {
|
||||||
int v;
|
int v;
|
||||||
|
|
||||||
/* Round the tiling up to the next power-of-two and the
|
/* Round the tiling up to the next power-of-two and the
|
||||||
@ -111,8 +111,8 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
|||||||
bo_size = size;
|
bo_size = size;
|
||||||
gem_handle = gem_create(fd, bo_size);
|
gem_handle = gem_create(fd, bo_size);
|
||||||
|
|
||||||
if (tiled)
|
if (tiling)
|
||||||
ret = __gem_set_tiling(fd, gem_handle, I915_TILING_X, stride);
|
ret = __gem_set_tiling(fd, gem_handle, tiling, stride);
|
||||||
|
|
||||||
*stride_ret = stride;
|
*stride_ret = stride;
|
||||||
*size_ret = size;
|
*size_ret = size;
|
||||||
@ -384,7 +384,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
|
|||||||
* @width: width of the framebuffer in pixel
|
* @width: width of the framebuffer in pixel
|
||||||
* @height: height of the framebuffer in pixel
|
* @height: height of the framebuffer in pixel
|
||||||
* @format: drm fourcc pixel format code
|
* @format: drm fourcc pixel format code
|
||||||
* @tiled: X-tiled or linear framebuffer
|
* @tiling: tiling layout of the framebuffer
|
||||||
* @fb: pointer to an #igt_fb structure
|
* @fb: pointer to an #igt_fb structure
|
||||||
* @bo_size: size of the backing bo (0 for minimum needed size)
|
* @bo_size: size of the backing bo (0 for minimum needed size)
|
||||||
*
|
*
|
||||||
@ -399,9 +399,10 @@ 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
|
* The kms id of the created framebuffer on success or a negative error code on
|
||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
unsigned int
|
||||||
uint32_t format, bool tiled,
|
igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||||
struct igt_fb *fb, unsigned bo_size)
|
uint32_t format, unsigned int tiling,
|
||||||
|
struct igt_fb *fb, unsigned bo_size)
|
||||||
{
|
{
|
||||||
uint32_t handles[4];
|
uint32_t handles[4];
|
||||||
uint32_t pitches[4];
|
uint32_t pitches[4];
|
||||||
@ -413,7 +414,7 @@ unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
memset(fb, 0, sizeof(*fb));
|
memset(fb, 0, sizeof(*fb));
|
||||||
|
|
||||||
bpp = igt_drm_format_to_bpp(format);
|
bpp = igt_drm_format_to_bpp(format);
|
||||||
ret = create_bo_for_fb(fd, width, height, bpp, tiled, &fb->gem_handle,
|
ret = create_bo_for_fb(fd, width, height, bpp, tiling, &fb->gem_handle,
|
||||||
&fb->size, &fb->stride, bo_size);
|
&fb->size, &fb->stride, bo_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -432,7 +433,7 @@ unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
|
|
||||||
fb->width = width;
|
fb->width = width;
|
||||||
fb->height = height;
|
fb->height = height;
|
||||||
fb->tiling = tiled;
|
fb->tiling = tiling;
|
||||||
fb->drm_format = format;
|
fb->drm_format = format;
|
||||||
fb->fb_id = fb_id;
|
fb->fb_id = fb_id;
|
||||||
|
|
||||||
@ -445,7 +446,7 @@ unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
* @width: width of the framebuffer in pixel
|
* @width: width of the framebuffer in pixel
|
||||||
* @height: height of the framebuffer in pixel
|
* @height: height of the framebuffer in pixel
|
||||||
* @format: drm fourcc pixel format code
|
* @format: drm fourcc pixel format code
|
||||||
* @tiled: X-tiled or linear framebuffer
|
* @tiling: tiling layout of the framebuffer
|
||||||
* @fb: pointer to an #igt_fb structure
|
* @fb: pointer to an #igt_fb structure
|
||||||
*
|
*
|
||||||
* This function allocates a gem buffer object suitable to back a framebuffer
|
* This function allocates a gem buffer object suitable to back a framebuffer
|
||||||
@ -460,9 +461,9 @@ unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
|||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||||
bool tiled, struct igt_fb *fb)
|
unsigned int tiling, struct igt_fb *fb)
|
||||||
{
|
{
|
||||||
return igt_create_fb_with_bo_size(fd, width, height, format, tiled, fb, 0);
|
return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -471,7 +472,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
|||||||
* @width: width of the framebuffer in pixel
|
* @width: width of the framebuffer in pixel
|
||||||
* @height: height of the framebuffer in pixel
|
* @height: height of the framebuffer in pixel
|
||||||
* @format: drm fourcc pixel format code
|
* @format: drm fourcc pixel format code
|
||||||
* @tiled: X-tiled or linear framebuffer
|
* @tiling: tiling layout of the framebuffer
|
||||||
* @r: red value to use as fill color
|
* @r: red value to use as fill color
|
||||||
* @g: gree value to use as fill color
|
* @g: gree value to use as fill color
|
||||||
* @b: blue value to use as fill color
|
* @b: blue value to use as fill color
|
||||||
@ -489,14 +490,14 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
|||||||
* failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
unsigned int igt_create_color_fb(int fd, int width, int height,
|
unsigned int igt_create_color_fb(int fd, int width, int height,
|
||||||
uint32_t format, bool tiled,
|
uint32_t format, unsigned int tiling,
|
||||||
double r, double g, double b,
|
double r, double g, double b,
|
||||||
struct igt_fb *fb /* out */)
|
struct igt_fb *fb /* out */)
|
||||||
{
|
{
|
||||||
unsigned int fb_id;
|
unsigned int fb_id;
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
|
|
||||||
fb_id = igt_create_fb(fd, width, height, format, tiled, fb);
|
fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
|
||||||
igt_assert(fb_id);
|
igt_assert(fb_id);
|
||||||
|
|
||||||
cr = igt_get_cairo_ctx(fd, fb);
|
cr = igt_get_cairo_ctx(fd, fb);
|
||||||
|
17
lib/igt_fb.h
17
lib/igt_fb.h
@ -41,6 +41,8 @@ typedef struct _cairo cairo_t;
|
|||||||
#include <drm_fourcc.h>
|
#include <drm_fourcc.h>
|
||||||
#include <xf86drmMode.h>
|
#include <xf86drmMode.h>
|
||||||
|
|
||||||
|
#include <i915_drm.h>
|
||||||
|
|
||||||
/* helpers to create nice-looking framebuffers */
|
/* helpers to create nice-looking framebuffers */
|
||||||
struct igt_fb {
|
struct igt_fb {
|
||||||
uint32_t fb_id;
|
uint32_t fb_id;
|
||||||
@ -63,15 +65,16 @@ enum igt_text_align {
|
|||||||
align_hcenter = 0x08,
|
align_hcenter = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
unsigned int igt_create_fb_with_bo_size(int fd, int width, int height,
|
unsigned int
|
||||||
uint32_t format, bool tiled,
|
igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||||
struct igt_fb *fb, unsigned bo_size);
|
uint32_t format, unsigned int tiling,
|
||||||
|
struct igt_fb *fb, unsigned bo_size);
|
||||||
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
|
||||||
bool tiled, struct igt_fb *fb);
|
unsigned int , struct igt_fb *fb);
|
||||||
unsigned int igt_create_color_fb(int fd, int width, int height,
|
unsigned int igt_create_color_fb(int fd, int width, int height,
|
||||||
uint32_t format, bool tiled,
|
uint32_t format, unsigned int tiling,
|
||||||
double r, double g, double b,
|
double r, double g, double b,
|
||||||
struct igt_fb *fb /* out */);
|
struct igt_fb *fb /* out */);
|
||||||
void igt_remove_fb(int fd, struct igt_fb *fb);
|
void igt_remove_fb(int fd, struct igt_fb *fb);
|
||||||
|
|
||||||
/* cairo-based painting */
|
/* cairo-based painting */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user