#10775·lvgl

D/AVE 2D broken for displays with higher resolution than 1024x1024

Author: QCEImreKorfCreated Sep 28, 2026Updated Sep 30, 2026

LVGL version

v9.6.0

Platform

e2 studio 2025-07, FSP version 6.5.0 on EK-RA8P1 development board. Display was connected with the parallel (16bit rgb565) output of the r_glcd driver.

What happened?

I was experimenting with the demo application on a display (1280x800) on the EK-RA8P1 development board (using the r_glcd driver) and noticed that enabling LV_USE_DRAW_DAVE2D the background gave a glitched background, the smaller widgets work fine.

Image

After some debugging I found out that the dave2d has a primitive size limit of 1024x1024 https://renesas.github.io/fsp/group___d_r_w.html which is smaller than my display.

I fixed it by modifying the d2_renderbox() call to dave2d_renderbox_split() and adding a _dave2d_task_in_hw_limits

c
/* D/AVE 2D hardware limits (FSP r_drw documentation):
 * - coordinates: -2048 .. 2047 (1:11:4 fixed point)
 * - size of a single primitive: 1024 x 1024 (10:4 fixed point)
 * Larger values silently wrap around (e.g. a 1280 px wide box is drawn 256 px wide). */
#define LV_DAVE2D_COORD_MIN      (-2048)
#define LV_DAVE2D_COORD_MAX      (2047)
#define LV_DAVE2D_MAX_PRIM_SIZE  (1016) /* stay a bit below 1024 to be safe with anti-aliasing */

/**
 * Render an axis aligned, integer box clipped to `clip`, split into chunks of at most
 * LV_DAVE2D_MAX_PRIM_SIZE x LV_DAVE2D_MAX_PRIM_SIZE pixels (D/AVE 2D primitive size limit).
 */
static void dave2d_renderbox_split(d2_device * handle, const lv_area_t * box, const lv_area_t * clip)
{
    lv_area_t a;
    if(!lv_area_intersect(&a, box, clip)) return;

    for(int32_t y = a.y1; y <= a.y2; y += LV_DAVE2D_MAX_PRIM_SIZE) {
        int32_t h = LV_MIN(LV_DAVE2D_MAX_PRIM_SIZE, a.y2 - y + 1);
        for(int32_t x = a.x1; x <= a.x2; x += LV_DAVE2D_MAX_PRIM_SIZE) {
            int32_t w = LV_MIN(LV_DAVE2D_MAX_PRIM_SIZE, a.x2 - x + 1);
            d2_s32 result = d2_renderbox(handle, (d2_point)D2_FIX4(x), (d2_point)D2_FIX4(y),
                                         (d2_width)D2_FIX4(w), (d2_width)D2_FIX4(h));
            LV_ASSERT(D2_OK == result);
            LV_UNUSED(result);
        }
    }
}

/**
 * Check the D/AVE 2D hardware limits for a task (see LV_DAVE2D_* in lv_draw_dave2d.h).
 * Fills are split into allowed chunks by the fill renderer, so only their coordinate range is checked.
 */
static bool _dave2d_task_in_hw_limits(const lv_draw_task_t * t, const lv_layer_t * layer)
{
    lv_area_t a = t->area;
    lv_area_move(&a, -layer->buf_area.x1, -layer->buf_area.y1);

    if(a.x1 < LV_DAVE2D_COORD_MIN || a.y1 < LV_DAVE2D_COORD_MIN ||
       a.x2 > LV_DAVE2D_COORD_MAX || a.y2 > LV_DAVE2D_COORD_MAX) {
        return false;
    }

    if(t->type != LV_DRAW_TASK_TYPE_FILL &&
       (lv_area_get_width(&a) > LV_DAVE2D_MAX_PRIM_SIZE || lv_area_get_height(&a) > LV_DAVE2D_MAX_PRIM_SIZE)) {
        return false;
    }

    return true;
}

I added the _dave2d_task_in_hw_limits call in the _dave2d_evaluate call after the lv_draw_dave2d_is_dest_cf_supported The dave2d_renderbox_split is a replacement for the d2_renderbox().

I realize that this is a crude fix as blit images are supported for 2047x1024 which are currently just offloaded to the cpu.

Extra note, this fix was implemented using claude code AI, but I have tested and verified it myself. The minimal example below was written by myself.

Another bug I found was that enabling HELIUM via #define LV_USE_NATIVE_HELIUM_ASM 1 #define LV_USE_DRAW_SW_ASM LV_DRAW_SW_ASM_HELIUM Results in compile errors:

../lib/lvgl/src/widgets/span/../../core/../draw/sw/blend/helium/lv_blend_helium.h:1291:19: error: invalid use of incomplete typedef 'lv_draw_sw_blend_image_dsc_t' {aka 'struct _lv_draw_sw_blend_image_dsc_t'}

However this should probably be a separate issue(?)

How to reproduce?

Config changes from template: #define LV_MEM_SIZE (256 * 1024U) /**< [bytes] */ #define LV_USE_OS LV_OS_FREERTOS #define LV_DEF_REFR_PERIOD 16 #define LV_DRAW_BUF_ALIGN 8 #define LV_USE_DRAW_DAVE2D 1 #define LV_USE_FLOAT 1 #define LV_USE_RENESAS_GLCDC 1 #define LV_USE_SYSMON 1 #define LV_USE_PERF_MONITOR 1 #define LV_USE_DEMO_WIDGETS 1

configuration.xml

c
// hal_warmstart.c

#include "hal_data.h"
#include <FreeRTOS.h>
#include <task.h>

FSP_CPP_HEADER
void R_BSP_WarmStart(bsp_warm_start_event_t event);

FSP_CPP_FOOTER

void vApplicationMallocFailedHook( void )
{
    __BKPT(0);
}

void R_BSP_WarmStart (bsp_warm_start_event_t event)
{
    if (BSP_WARM_START_RESET == event)
    {
#if BSP_FEATURE_FLASH_LP_VERSION != 0

        /* Enable reading from data flash. */
        R_FACI_LP->DFLCTL = 1U;

        /* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
         * C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
    }

#if BSP_CFG_OSPI_B_STARTUP_ENABLED && defined(BSP_CFG_OSPI_B_STARTUP_FN)
    if (BSP_WARM_START_POST_CLOCK == event)
    {
        /* Setup OSPI_B SiP flash and initialize it. */
        R_BSP_OspiBInit(BSP_CFG_OSPI_B_STARTUP_FN, true);
    }
#endif

    if (BSP_WARM_START_POST_C == event)
    {
        /* C runtime environment and system clocks are setup. */

        fsp_err_t fsp_err = FSP_SUCCESS;

        /* Enable individual fault handlers */
        SCB->SHCSR |= (SCB_SHCSR_USGFAULTENA_Msk | \
                   SCB_SHCSR_BUSFAULTENA_Msk | \
                   SCB_SHCSR_MEMFAULTENA_Msk |
                   SCB_SHCSR_SECUREFAULTENA_Msk);

        /* Configure pins. */
        fsp_err = g_ioport.p_api->open(g_ioport.p_ctrl, g_ioport.p_cfg);
        assert(FSP_SUCCESS == fsp_err);
        #if BSP_CFG_SDRAM_ENABLED
            /* Setup SDRAM and initialize it. Must configure pins first. */
            R_BSP_SdramInit(true);
        #endif
    }
}


// LVGL_thread_entry.cpp

#include "LVGL_thread.h"
#include "lvgl/demos/widgets/lv_demo_widgets.h"
#include "r_drw_cfg.h"
extern "C" {
#include "lvgl/lvgl.h"
}

const timer_instance_t& m_backlight         = g_backlight_timer;
const gpt_io_pin_t      m_backlight_gpt_pin = GPT_IO_PIN_GTIOCB;

constexpr size_t LVGL_TICK_MS = 1;

auto backlight(unsigned int level) -> fsp_err_t;

extern "C" {
    /* HMI Thread entry function */
    void LVGL_thread_entry(void* pvParameters)
    {
        (void)pvParameters;

        fsp_err_t fsp_err = FSP_SUCCESS;

        // start backlight
        fsp_err = m_backlight.p_api->open(m_backlight.p_ctrl, m_backlight.p_cfg);
        assert(FSP_SUCCESS == fsp_err);

        fsp_err = m_backlight.p_api->start(m_backlight.p_ctrl);
        assert(FSP_SUCCESS == fsp_err);

        // create lvgl demo application with gt911 controller
        lv_init();
        lv_display_t* m_disp  = lv_renesas_glcdc_direct_create();

        lv_display_set_default(m_disp);

        fsp_err = g_lvgl_timer.p_api->open(g_lvgl_timer.p_ctrl, g_lvgl_timer.p_cfg);
        assert(FSP_SUCCESS == fsp_err);

        fsp_err = g_lvgl_timer.p_api->start(g_lvgl_timer.p_ctrl);
        assert(FSP_SUCCESS == fsp_err);

        lv_demo_widgets();

        for (;;) {
            lv_timer_handler();
            vTaskDelay(1);
        }
    }
}

void fsp_lvgl_tick_callback(timer_callback_args_t* p_args)
{
    if (p_args->event == TIMER_EVENT_CYCLE_END) {
        lv_tick_inc(LVGL_TICK_MS);
    }
}

extern "C" {
#if DRW_CFG_CUSTOM_MALLOC
void* d1_malloc(size_t size) { return lv_malloc(size); }

void d1_free(void* ptr) { lv_free(ptr); }

#endif
}