[Mesa-dev] brw_context::upload questions
kevin.rogovin at intel.com
Thu Nov 7 23:58:09 PST 2013
I was poking through the code tracking what is happening to brw_context::upload.bo, and it left me scrathing me head. As Paul Berry told me, I see that is used to just store client side index and vertex buffers (copied to it essentially be copy_array_to_vbo_array() and brw_upload_indices()), but the reference counting on it has me royally confused:
I see that intel_upload_data() adds a reference and "returns" it via return_bo. Now, brw_upload_indices() will remove a reference as well, so the effect is that it will not change the reference count. On the other hand, copy_array_to_vbo_array() calls intel_upload_data() but does not unreference it, so that leaves the reference counted incremented by one [or it can do map/unmap which also leave the reference one higher as well].
Finally, I get to my question, in intel_upload_finish(), the reference count is decremented after an upload via drm. It looks to me like that then, if an application chooses to source from client side for indices but use buffer object vertices, then the upload.bo will get killed off on intel_upload(), and thus if a command refers to it, it refers to a dead bo.
What am I missing?
Also, why is not this kind of thing handled in the VBO module where the VBO module tracks if data is backed by a buffer object or not and use the driver interface to manage it? That way any driver could just assume that all index and vertex data is backed by a buffer object and potentially simplify the code.
More information about the mesa-dev