mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-22 23:36:30 +00:00
lib/igt_fb: make the automatic buffer sizes/strides smaller
The big motivation behind this patch is that the current power-of-two granularity from igt_fb is way too big. There was more than one occasion where I had to work around this problem on kms_frontbuffer_tracking, and during my last workaround I was requested to just make igt_fb use more minimal buffers. I also need to export the size computation function so I won't need to reimplement it inside kms_frontbuffer_tracking. v2: - Fix the Yf sizes (Ville). - Don't change the Gen 2/3 behavior for both tiled and non-tiled. v3: - Edit the commit message, clarify that v1 was wrongly treating gen 2/3 non-tiled as tiled (Chris). Requested-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
This commit is contained in:
parent
d63e72f0ad
commit
be6f3fadaf
109
lib/igt_fb.c
109
lib/igt_fb.c
@ -32,6 +32,7 @@
|
|||||||
#include "drmtest.h"
|
#include "drmtest.h"
|
||||||
#include "igt_fb.h"
|
#include "igt_fb.h"
|
||||||
#include "ioctl_wrappers.h"
|
#include "ioctl_wrappers.h"
|
||||||
|
#include "intel_chipset.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SECTION:igt_fb
|
* SECTION:igt_fb
|
||||||
@ -72,26 +73,88 @@ static struct format_desc_struct {
|
|||||||
#define for_each_format(f) \
|
#define for_each_format(f) \
|
||||||
for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
|
for (f = format_desc; f - format_desc < ARRAY_SIZE(format_desc); f++)
|
||||||
|
|
||||||
|
static void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
|
||||||
|
unsigned *width_ret, unsigned *height_ret)
|
||||||
|
{
|
||||||
|
uint32_t devid = intel_get_drm_devid(fd);
|
||||||
|
|
||||||
/* helpers to create nice-looking framebuffers */
|
switch (tiling) {
|
||||||
static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
case LOCAL_DRM_FORMAT_MOD_NONE:
|
||||||
uint64_t tiling, unsigned bo_size,
|
*width_ret = 64;
|
||||||
unsigned bo_stride, uint32_t *gem_handle_ret,
|
*height_ret = 1;
|
||||||
|
break;
|
||||||
|
case LOCAL_I915_FORMAT_MOD_X_TILED:
|
||||||
|
if (intel_gen(devid) == 2) {
|
||||||
|
*width_ret = 128;
|
||||||
|
*height_ret = 16;
|
||||||
|
} else {
|
||||||
|
*width_ret = 512;
|
||||||
|
*height_ret = 8;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LOCAL_I915_FORMAT_MOD_Y_TILED:
|
||||||
|
if (IS_915(devid))
|
||||||
|
*width_ret = 512;
|
||||||
|
else
|
||||||
|
*width_ret = 128;
|
||||||
|
*height_ret = 32;
|
||||||
|
break;
|
||||||
|
case LOCAL_I915_FORMAT_MOD_Yf_TILED:
|
||||||
|
switch (fb_bpp) {
|
||||||
|
case 8:
|
||||||
|
*width_ret = 64;
|
||||||
|
*height_ret = 64;
|
||||||
|
break;
|
||||||
|
case 16:
|
||||||
|
case 32:
|
||||||
|
*width_ret = 128;
|
||||||
|
*height_ret = 32;
|
||||||
|
break;
|
||||||
|
case 64:
|
||||||
|
case 128:
|
||||||
|
*width_ret = 256;
|
||||||
|
*height_ret = 16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
igt_assert(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
igt_assert(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* igt_calc_fb_size:
|
||||||
|
* @fd: the DRM file descriptor
|
||||||
|
* @width: width of the framebuffer in pixels
|
||||||
|
* @height: height of the framebuffer in pixels
|
||||||
|
* @bpp: bytes per pixel of the framebuffer
|
||||||
|
* @tiling: tiling layout of the framebuffer (as framebuffer modifier)
|
||||||
|
* @size_ret: returned size for the framebuffer
|
||||||
|
* @stride_ret: returned stride for the framebuffer
|
||||||
|
*
|
||||||
|
* This function returns valid stride and size values for a framebuffer with the
|
||||||
|
* specified parameters.
|
||||||
|
*/
|
||||||
|
void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling,
|
||||||
unsigned *size_ret, unsigned *stride_ret)
|
unsigned *size_ret, unsigned *stride_ret)
|
||||||
{
|
{
|
||||||
uint32_t gem_handle;
|
unsigned int tile_width, tile_height, stride, size;
|
||||||
int size, ret = 0;
|
int byte_width = width * (bpp / 8);
|
||||||
unsigned stride;
|
|
||||||
|
|
||||||
if (tiling != LOCAL_DRM_FORMAT_MOD_NONE) {
|
igt_get_fb_tile_size(fd, tiling, bpp, &tile_width, &tile_height);
|
||||||
|
|
||||||
|
if (intel_gen(intel_get_drm_devid(fd)) <= 3 &&
|
||||||
|
tiling != LOCAL_DRM_FORMAT_MOD_NONE) {
|
||||||
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 region
|
||||||
* region up to the next pot fence size so that this works
|
* up to the next pot fence size so that this works on all
|
||||||
* on all generations.
|
* generations.
|
||||||
*
|
*
|
||||||
* This can still fail if the framebuffer is too large to
|
* This can still fail if the framebuffer is too large to be
|
||||||
* be tiled. But then that failure is expected.
|
* tiled. But then that failure is expected.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
v = width * bpp / 8;
|
v = width * bpp / 8;
|
||||||
@ -102,11 +165,25 @@ static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
|||||||
for (size = 1024*1024; size < v; size *= 2)
|
for (size = 1024*1024; size < v; size *= 2)
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
/* Scan-out has a 64 byte alignment restriction */
|
stride = ALIGN(byte_width, tile_width);
|
||||||
stride = ALIGN(width * (bpp / 8), 64);
|
size = stride * ALIGN(height, tile_height);
|
||||||
size = stride * height;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*stride_ret = stride;
|
||||||
|
*size_ret = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* helpers to create nice-looking framebuffers */
|
||||||
|
static int create_bo_for_fb(int fd, int width, int height, int bpp,
|
||||||
|
uint64_t tiling, unsigned bo_size,
|
||||||
|
unsigned bo_stride, uint32_t *gem_handle_ret,
|
||||||
|
unsigned *size_ret, unsigned *stride_ret)
|
||||||
|
{
|
||||||
|
uint32_t gem_handle;
|
||||||
|
int ret = 0;
|
||||||
|
unsigned size, stride;
|
||||||
|
|
||||||
|
igt_calc_fb_size(fd, width, height, bpp, tiling, &size, &stride);
|
||||||
if (bo_size == 0)
|
if (bo_size == 0)
|
||||||
bo_size = size;
|
bo_size = size;
|
||||||
if (bo_stride == 0)
|
if (bo_stride == 0)
|
||||||
|
@ -69,6 +69,8 @@ enum igt_text_align {
|
|||||||
align_hcenter = 0x08,
|
align_hcenter = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void igt_calc_fb_size(int fd, int width, int height, int bpp, uint64_t tiling,
|
||||||
|
unsigned *size_ret, unsigned *stride_ret);
|
||||||
unsigned int
|
unsigned int
|
||||||
igt_create_fb_with_bo_size(int fd, int width, int height,
|
igt_create_fb_with_bo_size(int fd, int width, int height,
|
||||||
uint32_t format, uint64_t tiling,
|
uint32_t format, uint64_t tiling,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user