mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
ports/stm32: Fix NEMA GPU driver.
* You have to clean and invalidate the destination image so that the processor writes out the full image and so that the processor doesn't flush cache lines ontop of the GPU writing the image. * The ICACHE doesn't automatically flush itself after a draw operation. Depending on the situation, it will just hold the entire source image internally and never read it again. In particular, when scaling something like 160x120 it just caches the whole image and never reads it again.
This commit is contained in:
parent
43c6b6c5fd
commit
8f81f16963
@ -117,8 +117,13 @@ int omv_gpu_draw_image(image_t *src_img,
|
|||||||
nema_blit_subrect_fit(dst_rect->x, dst_rect->y, dst_rect->w, dst_rect->h,
|
nema_blit_subrect_fit(dst_rect->x, dst_rect->y, dst_rect->w, dst_rect->h,
|
||||||
src_rect->x, src_rect->y, src_rect->w, src_rect->h);
|
src_rect->x, src_rect->y, src_rect->w, src_rect->h);
|
||||||
|
|
||||||
|
// Ensures any cached writes to dst are flushed.
|
||||||
|
SCB_CleanInvalidateDCache_by_Addr(dst_img->data, image_size(dst_img));
|
||||||
// Flush source image
|
// Flush source image
|
||||||
SCB_CleanDCache_by_Addr(src_img->data, image_size(src_img));
|
SCB_CleanDCache_by_Addr(src_img->data, image_size(src_img));
|
||||||
|
// Ensure the GPU cache is clean before starting the GPU operation.
|
||||||
|
// Will start invalidating the GPU cache if not already invalidated.
|
||||||
|
HAL_ICACHE_WaitForInvalidateComplete();
|
||||||
|
|
||||||
nema_cl_submit(&cl);
|
nema_cl_submit(&cl);
|
||||||
nema_cl_wait(&cl);
|
nema_cl_wait(&cl);
|
||||||
@ -126,6 +131,9 @@ int omv_gpu_draw_image(image_t *src_img,
|
|||||||
nema_cl_destroy(&cl);
|
nema_cl_destroy(&cl);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Start invalidation of the GPU cache for the next operation.
|
||||||
|
// This is done asynchronously so that the CPU can continue working.
|
||||||
|
HAL_ICACHE_Invalidate_IT();
|
||||||
// Invalidate the destination image.
|
// Invalidate the destination image.
|
||||||
SCB_InvalidateDCache_by_Addr(dst_img->data, image_size(dst_img));
|
SCB_InvalidateDCache_by_Addr(dst_img->data, image_size(dst_img));
|
||||||
OMV_PROFILE_PRINT();
|
OMV_PROFILE_PRINT();
|
||||||
|
|||||||
@ -55,6 +55,7 @@ int32_t nema_sys_init(void) {
|
|||||||
// Configure and enable texture cache
|
// Configure and enable texture cache
|
||||||
HAL_ICACHE_DeInit();
|
HAL_ICACHE_DeInit();
|
||||||
HAL_ICACHE_Disable();
|
HAL_ICACHE_Disable();
|
||||||
|
HAL_ICACHE_WaitForInvalidateComplete();
|
||||||
HAL_ICACHE_ConfigAssociativityMode(ICACHE_4WAYS);
|
HAL_ICACHE_ConfigAssociativityMode(ICACHE_4WAYS);
|
||||||
HAL_ICACHE_Enable();
|
HAL_ICACHE_Enable();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user