aire39
Posts: 15
Joined: Sat Sep 23, 2017 10:43 am

Properly releasing VCSM attached to fbo

Thu May 09, 2019 7:23 pm

I provide this process where I do this vcsm -> egltexture -> opengl texture -> fbo and this works great but I have a situation where I need to restart this process. The problem comes when I restart the process it seems that the vcsm cannot generate a handle for me and so the program crashes.

When I shutdown the videochain I do delete the fbo, opengl texture, egltexture, and the vcsm buffer before restarting the process but I think the vcsm may not be deleting correctly.

Code: Select all

fbo is deleted then the below happens...

void ReleaseTextureVCSM()
{
	vcsm_unlock_hdl(vcsmInfo.vcsm_handle);
	glDeleteTextures(1, &oglVcsmTexture);
	eglDestroyImageKHR(eglManager->GetDisplay(), eglImageVcsm);
	vcsm_free(vcsmInfo.vcsm_handle);
}	
Is the code above a viable way to release the vcsm resource? Is it possible I'm forgetting something? Any comments about this would be appreciated.

aire39
Posts: 15
Joined: Sat Sep 23, 2017 10:43 am

Re: Properly releasing VCSM attached to fbo

Mon May 13, 2019 10:35 pm

I've noticed that when I try to release the isp component (vc.ril.isp) the resource/thread is never released. Is this a known issue? The other mmal components don't have this issue from what I can see.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6679
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Properly releasing VCSM attached to fbo

Tue May 14, 2019 6:17 am

aire39 wrote:
Mon May 13, 2019 10:35 pm
I've noticed that when I try to release the isp component (vc.ril.isp) the resource/thread is never released. Is this a known issue? The other mmal components don't have this issue from what I can see.
Your userland thread gets blocked, or something else happens? Test case please as generally the isp component is behaving pretty well.

vcsm does expose state through debugfs. IIRC You'll want to check /sys/kernel/debug/vcsm/state.
You can also check allocations on the VPU with "sudo vcdbg reloc", which should give you the lock count and refcount of each object. Something may still be holding a reference to the buffer incorrectly.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

aire39
Posts: 15
Joined: Sat Sep 23, 2017 10:43 am

Re: Properly releasing VCSM attached to fbo

Tue May 14, 2019 11:36 pm

Thanks, I wasn't aware of those debug options. I did eventually find out what was going on which was that I missed releasing a mmal buffer pool on the input port for the isp component. Once I destroyed the input ports memory pool for the isp component I was able to successfully release the isp component.

I'll take a look at the the debug options because my last bit of trouble has to do with re-initializing the vcsm buffers when restarting the videochain process from within the application.

Return to “Graphics programming”