mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 17:48:10 +02:00
pipebuffer, winsys/svga: Add functionality to update pb_validate_entry flags
In order to be able to add access modes to a pb_validate_entry, update the pb_validate_add_buffer function to take a pointer hash table and also to return whether the buffer was already on the validate list. Update the svga winsys accordingly. Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Charmaine Lee <charmainel@vmware.com>
This commit is contained in:
parent
a119da3bc9
commit
1a66ead1c7
3 changed files with 33 additions and 27 deletions
|
|
@ -37,6 +37,7 @@
|
||||||
#include "pipe/p_defines.h"
|
#include "pipe/p_defines.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/u_debug.h"
|
#include "util/u_debug.h"
|
||||||
|
#include "util/u_hash_table.h"
|
||||||
|
|
||||||
#include "pb_buffer.h"
|
#include "pb_buffer.h"
|
||||||
#include "pb_validate.h"
|
#include "pb_validate.h"
|
||||||
|
|
@ -63,9 +64,12 @@ struct pb_validate
|
||||||
enum pipe_error
|
enum pipe_error
|
||||||
pb_validate_add_buffer(struct pb_validate *vl,
|
pb_validate_add_buffer(struct pb_validate *vl,
|
||||||
struct pb_buffer *buf,
|
struct pb_buffer *buf,
|
||||||
enum pb_usage_flags flags)
|
enum pb_usage_flags flags,
|
||||||
|
struct util_hash_table *ht,
|
||||||
|
boolean *already_present)
|
||||||
{
|
{
|
||||||
assert(buf);
|
assert(buf);
|
||||||
|
*already_present = FALSE;
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return PIPE_ERROR;
|
return PIPE_ERROR;
|
||||||
|
|
||||||
|
|
@ -73,13 +77,18 @@ pb_validate_add_buffer(struct pb_validate *vl,
|
||||||
assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
|
assert(!(flags & ~PB_USAGE_GPU_READ_WRITE));
|
||||||
flags &= PB_USAGE_GPU_READ_WRITE;
|
flags &= PB_USAGE_GPU_READ_WRITE;
|
||||||
|
|
||||||
/* We only need to store one reference for each buffer, so avoid storing
|
if (ht) {
|
||||||
* consecutive references for the same buffer. It might not be the most
|
unsigned long entry_idx = (unsigned long) util_hash_table_get(ht, buf);
|
||||||
* common pattern, but it is easy to implement.
|
|
||||||
*/
|
if (entry_idx) {
|
||||||
if(vl->used && vl->entries[vl->used - 1].buf == buf) {
|
struct pb_validate_entry *entry = &vl->entries[entry_idx - 1];
|
||||||
vl->entries[vl->used - 1].flags |= flags;
|
|
||||||
return PIPE_OK;
|
assert(entry->buf == buf);
|
||||||
|
entry->flags |= flags;
|
||||||
|
*already_present = TRUE;
|
||||||
|
|
||||||
|
return PIPE_OK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Grow the table */
|
/* Grow the table */
|
||||||
|
|
@ -108,6 +117,9 @@ pb_validate_add_buffer(struct pb_validate *vl,
|
||||||
vl->entries[vl->used].flags = flags;
|
vl->entries[vl->used].flags = flags;
|
||||||
++vl->used;
|
++vl->used;
|
||||||
|
|
||||||
|
if (ht)
|
||||||
|
util_hash_table_set(ht, buf, (void *) (unsigned long) vl->used);
|
||||||
|
|
||||||
return PIPE_OK;
|
return PIPE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ extern "C" {
|
||||||
|
|
||||||
struct pb_buffer;
|
struct pb_buffer;
|
||||||
struct pipe_fence_handle;
|
struct pipe_fence_handle;
|
||||||
|
struct util_hash_table;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -59,7 +60,9 @@ struct pb_validate;
|
||||||
enum pipe_error
|
enum pipe_error
|
||||||
pb_validate_add_buffer(struct pb_validate *vl,
|
pb_validate_add_buffer(struct pb_validate *vl,
|
||||||
struct pb_buffer *buf,
|
struct pb_buffer *buf,
|
||||||
enum pb_usage_flags flags);
|
enum pb_usage_flags flags,
|
||||||
|
struct util_hash_table *ht,
|
||||||
|
boolean *already_present);
|
||||||
|
|
||||||
enum pipe_error
|
enum pipe_error
|
||||||
pb_validate_foreach(struct pb_validate *vl,
|
pb_validate_foreach(struct pb_validate *vl,
|
||||||
|
|
|
||||||
|
|
@ -370,24 +370,15 @@ vmw_swc_add_validate_buffer(struct vmw_svga_winsys_context *vswc,
|
||||||
struct pb_buffer *pb_buf,
|
struct pb_buffer *pb_buf,
|
||||||
unsigned flags)
|
unsigned flags)
|
||||||
{
|
{
|
||||||
enum pipe_error ret;
|
MAYBE_UNUSED enum pipe_error ret;
|
||||||
unsigned translated_flags;
|
unsigned translated_flags;
|
||||||
|
boolean already_present;
|
||||||
|
|
||||||
/*
|
translated_flags = vmw_translate_to_pb_flags(flags);
|
||||||
* TODO: Update pb_validate to provide a similar functionality
|
ret = pb_validate_add_buffer(vswc->validate, pb_buf, translated_flags,
|
||||||
* (Check buffer already present before adding)
|
vswc->hash, &already_present);
|
||||||
*/
|
assert(ret == PIPE_OK);
|
||||||
if (util_hash_table_get(vswc->hash, pb_buf) != pb_buf) {
|
return !already_present;
|
||||||
translated_flags = vmw_translate_to_pb_flags(flags);
|
|
||||||
ret = pb_validate_add_buffer(vswc->validate, pb_buf, translated_flags);
|
|
||||||
/* TODO: Update pipebuffer to reserve buffers and not fail here */
|
|
||||||
assert(ret == PIPE_OK);
|
|
||||||
(void)ret;
|
|
||||||
(void)util_hash_table_set(vswc->hash, pb_buf, pb_buf);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue