mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-31 05:08:12 +02:00
pb_bufmgr_cache: add is_buffer_busy hook and use it instead of non-blocking map
This is cleaner and implementing the hook is optional.
This commit is contained in:
parent
588fa884d2
commit
49579a4df8
2 changed files with 14 additions and 7 deletions
|
|
@ -82,6 +82,10 @@ struct pb_manager
|
|||
*/
|
||||
void
|
||||
(*flush)( struct pb_manager *mgr );
|
||||
|
||||
boolean
|
||||
(*is_buffer_busy)( struct pb_manager *mgr,
|
||||
struct pb_buffer *buf );
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -227,8 +227,6 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
|
|||
pb_size size,
|
||||
const struct pb_desc *desc)
|
||||
{
|
||||
void *map;
|
||||
|
||||
if(buf->base.base.size < size)
|
||||
return 0;
|
||||
|
||||
|
|
@ -242,13 +240,18 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
|
|||
if(!pb_check_usage(desc->usage, buf->base.base.usage))
|
||||
return 0;
|
||||
|
||||
map = pb_map(buf->buffer, PB_USAGE_DONTBLOCK, NULL);
|
||||
if (!map) {
|
||||
return -1;
|
||||
if (buf->mgr->provider->is_buffer_busy) {
|
||||
if (buf->mgr->provider->is_buffer_busy(buf->mgr->provider, buf->buffer))
|
||||
return -1;
|
||||
} else {
|
||||
void *ptr = pb_map(buf->buffer, PB_USAGE_DONTBLOCK, NULL);
|
||||
|
||||
if (!ptr)
|
||||
return -1;
|
||||
|
||||
pb_unmap(buf->buffer);
|
||||
}
|
||||
|
||||
pb_unmap(buf->buffer);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue