iter2 Fix 1: invalidate format cache on DestroyContext + REQBUFS(0) on CAPTURE in resolution-change path
Fix 1 of iteration 2 per phase4_iter2_plan.md. Adds surface_reset_format_cache() exposed from src/surface.h. Called from RequestDestroyContext after the dual REQBUFS(0). Without this, multi-video Firefox sessions on mozilla.org corrupted the next session's CAPTURE format query: the kernel reset to defaults but our LAST_OUTPUT_WIDTH/HEIGHT cache still said 'already 1920x1088,' so the next G_FMT returned 48x48 and the exported descriptor encoded wrong pitch/offset. Also adds REQBUFS(0) on CAPTURE in the resolution-change path of RequestCreateSurfaces2 (Sonnet Phase 5 review iter2 9.1). The existing code only did REQBUFS(0) on OUTPUT before re-S_FMTting; hantro derives CAPTURE format from OUTPUT format, so leftover CAPTURE buffers from the prior resolution would also block the implicit format change. Pre-existing bug surfaced by Sonnet's audit; Fix 3 pool refactor would have exposed it more often. Limitation noted in surface.h docblock: the LAST_OUTPUT_WIDTH/ HEIGHT cache is a static process-global, so concurrent multi- context use still races (Sonnet 7.3 / 9.6). Iteration 2 only addresses sequential sessions. Multi-context safety is iteration 3+. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -126,4 +126,24 @@ VAStatus RequestExportSurfaceHandle(VADriverContextP context,
|
||||
VASurfaceID surface_id, uint32_t mem_type,
|
||||
uint32_t flags, void *descriptor);
|
||||
|
||||
/*
|
||||
* Iteration 2 Fix 1: invalidate the LAST_OUTPUT_WIDTH/HEIGHT cache used
|
||||
* by RequestCreateSurfaces2 to skip redundant v4l2_set_format calls.
|
||||
*
|
||||
* Must be called when the kernel's CAPTURE format state is no longer
|
||||
* guaranteed to match what we last set on OUTPUT — at minimum, on
|
||||
* RequestDestroyContext after REQBUFS(0). Without this, Firefox
|
||||
* playing a multi-video page (mozilla.org with 864-wide intro
|
||||
* videos at varying resolutions) corrupts the next session's CAPTURE
|
||||
* format query: the cache says "already 1920x1088" while the kernel
|
||||
* has reset to defaults, our subsequent G_FMT returns 48x48, and the
|
||||
* exported descriptor encodes wrong pitch/offset.
|
||||
*
|
||||
* Limitation (Sonnet Phase 5 review 7.3 / 9.6): the cache is a
|
||||
* static process-global, so concurrent multi-context use still races.
|
||||
* Iteration 2 only addresses sequential sessions. Multi-context
|
||||
* safety is iteration 3+ scope.
|
||||
*/
|
||||
void surface_reset_format_cache(void);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user