DISPMANX: implement pitch alignment for better videocore blitting performance

This commit is contained in:
vanfanel 2017-01-14 23:01:05 +01:00
parent 8640522073
commit 869a050a18

View File

@ -239,8 +239,9 @@ static void dispmanx_surface_setup(void *data, int src_width, int src_height,
/* Setup surface parameters */ /* Setup surface parameters */
surface->numpages = numpages; surface->numpages = numpages;
/* We receive the pitch for what we consider "useful info", /* We receive the pitch for what we consider "useful info",
* excluding things that are between scanlines. */ * excluding things that are between scanlines.
surface->pitch = visible_pitch; * Then we align it to 16 pixels (not bytes) for performance reasons. */
surface->pitch = ALIGN_UP(visible_pitch, (pixformat == VC_IMAGE_XRGB8888 ? 64 : 32));
/* Transparency disabled */ /* Transparency disabled */
surface->alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS; surface->alpha.flags = DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS;
@ -262,7 +263,7 @@ static void dispmanx_surface_setup(void *data, int src_width, int src_height,
/* The "visible" width obtained from the core pitch. We blit based on /* The "visible" width obtained from the core pitch. We blit based on
* the "visible" width, for cores with things between scanlines. */ * the "visible" width, for cores with things between scanlines. */
int visible_width = visible_pitch / (bpp / 8); int visible_width = visible_pitch / (bpp / 8);
dst_width = _dispvars->dispmanx_height * aspect; dst_width = _dispvars->dispmanx_height * aspect;
dst_height = _dispvars->dispmanx_height; dst_height = _dispvars->dispmanx_height;
@ -335,17 +336,6 @@ static void dispmanx_surface_update(void *data, const void *frame,
slock_lock(_dispvars->pending_mutex); slock_lock(_dispvars->pending_mutex);
_dispvars->pageflip_pending++; _dispvars->pageflip_pending++;
slock_unlock(_dispvars->pending_mutex); slock_unlock(_dispvars->pending_mutex);
if (settings->video.max_swapchain_images <= 2)
{
/* Wait for page flip before continuing, i.e. do not allow core to run
* ahead. This reduces input lag, but is less forgiving performance-
* wise. */
slock_lock(_dispvars->pending_mutex);
if (_dispvars->pageflip_pending > 0)
scond_wait(_dispvars->vsync_condition, _dispvars->pending_mutex);
slock_unlock(_dispvars->pending_mutex);
}
} }
/* Enable/disable bilinear filtering. */ /* Enable/disable bilinear filtering. */
@ -359,17 +349,16 @@ static void dispmanx_set_scaling (bool bilinear_filter)
static void dispmanx_blank_console (void *data) static void dispmanx_blank_console (void *data)
{ {
/* Note that a 2-pixels array is needed to accomplish console blanking because with 1-pixel /* Since pitch will be aligned to 16 pixels (not bytes) we use a
* only the write data function doesn't work well, so when we do the only resource * 16 pixels image to save the alignment */
* change in the surface update function, we will be seeing a distorted console. */
struct dispmanx_video *_dispvars = data; struct dispmanx_video *_dispvars = data;
uint16_t image[2] = {0x0000, 0x0000}; uint16_t image[16] = {0x0000};
float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height; float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height;
dispmanx_surface_setup(_dispvars, dispmanx_surface_setup(_dispvars,
2, 16,
2, 1,
4, 32,
16, 16,
VC_IMAGE_RGB565, VC_IMAGE_RGB565,
255, 255,