aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys/svga
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2019-03-05 14:20:29 -0700
committerBrian Paul <[email protected]>2019-03-08 07:40:35 -0700
commit76a10fc89e73a21771523a8c343c8f5727fbe16a (patch)
tree2efe6e08ff331904bba3c90023367d3e3d514331 /src/gallium/winsys/svga
parentb5f2b0d6b6ab462d5d8732a17493af2da400a9ef (diff)
winsys/svga: use new pb_usage_flags enum type
And add a comment that we're implicitly converting PIPE_TRANSFER_ flags to PB_USAGE_ flags in one place. And statically assert that the enum values match. Reviewed-by: Neha Bhende <[email protected]> Reviewed-by: Thomas Hellstrom <[email protected]>
Diffstat (limited to 'src/gallium/winsys/svga')
-rw-r--r--src/gallium/winsys/svga/drm/vmw_buffer.c27
-rw-r--r--src/gallium/winsys/svga/drm/vmw_buffer.h1
-rw-r--r--src/gallium/winsys/svga/drm/vmw_context.c4
3 files changed, 26 insertions, 6 deletions
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c
index 3ac80c7caf5..91b5b259435 100644
--- a/src/gallium/winsys/svga/drm/vmw_buffer.c
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.c
@@ -90,6 +90,11 @@ static inline struct vmw_gmr_bufmgr *
vmw_gmr_bufmgr(struct pb_manager *mgr)
{
assert(mgr);
+
+ /* Make sure our extra flags don't collide with pipebuffer's flags */
+ STATIC_ASSERT((VMW_BUFFER_USAGE_SHARED & PB_USAGE_ALL) == 0);
+ STATIC_ASSERT((VMW_BUFFER_USAGE_SYNC & PB_USAGE_ALL) == 0);
+
return (struct vmw_gmr_bufmgr *)mgr;
}
@@ -109,7 +114,7 @@ vmw_gmr_buffer_destroy(struct pb_buffer *_buf)
static void *
vmw_gmr_buffer_map(struct pb_buffer *_buf,
- unsigned flags,
+ enum pb_usage_flags flags,
void *flush_ctx)
{
struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
@@ -140,7 +145,7 @@ static void
vmw_gmr_buffer_unmap(struct pb_buffer *_buf)
{
struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);
- unsigned flags = buf->map_flags;
+ enum pb_usage_flags flags = buf->map_flags;
if ((_buf->usage & VMW_BUFFER_USAGE_SYNC) &&
!(flags & PB_USAGE_UNSYNCHRONIZED)) {
@@ -164,7 +169,7 @@ vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,
static enum pipe_error
vmw_gmr_buffer_validate( struct pb_buffer *_buf,
struct pb_validate *vl,
- unsigned flags )
+ enum pb_usage_flags flags )
{
/* Always pinned */
return PIPE_OK;
@@ -338,7 +343,7 @@ vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,
void *
vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
struct svga_winsys_buffer *buf,
- unsigned flags)
+ enum pipe_transfer_usage flags)
{
void *map;
@@ -346,6 +351,20 @@ vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,
if (flags & PIPE_TRANSFER_UNSYNCHRONIZED)
flags &= ~PIPE_TRANSFER_DONTBLOCK;
+ /* NOTE: we're passing PIPE_TRANSFER_x flags instead of
+ * PB_USAGE_x flags here. We should probably fix that.
+ */
+ STATIC_ASSERT((unsigned) PB_USAGE_CPU_READ ==
+ (unsigned) PIPE_TRANSFER_READ);
+ STATIC_ASSERT((unsigned) PB_USAGE_CPU_WRITE ==
+ (unsigned) PIPE_TRANSFER_WRITE);
+ STATIC_ASSERT((unsigned) PB_USAGE_GPU_READ ==
+ (unsigned) PIPE_TRANSFER_MAP_DIRECTLY);
+ STATIC_ASSERT((unsigned) PB_USAGE_DONTBLOCK ==
+ (unsigned) PIPE_TRANSFER_DONTBLOCK);
+ STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED ==
+ (unsigned) PIPE_TRANSFER_UNSYNCHRONIZED);
+
map = pb_map(vmw_pb_buffer(buf), flags, NULL);
#ifdef DEBUG
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.h b/src/gallium/winsys/svga/drm/vmw_buffer.h
index 6e1151e5f36..8ed56d4aa1e 100644
--- a/src/gallium/winsys/svga/drm/vmw_buffer.h
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.h
@@ -33,6 +33,7 @@
#include "util/u_debug_flush.h"
+/* These extra flags are used wherever the pb_usage_flags enum type is used */
#define VMW_BUFFER_USAGE_SHARED (1 << 20)
#define VMW_BUFFER_USAGE_SYNC (1 << 21)
diff --git a/src/gallium/winsys/svga/drm/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c
index c0ee833e334..59963ff7a82 100644
--- a/src/gallium/winsys/svga/drm/vmw_context.c
+++ b/src/gallium/winsys/svga/drm/vmw_context.c
@@ -161,10 +161,10 @@ vmw_svga_winsys_context(struct svga_winsys_context *swc)
}
-static inline unsigned
+static inline enum pb_usage_flags
vmw_translate_to_pb_flags(unsigned flags)
{
- unsigned f = 0;
+ enum pb_usage_flags f = 0;
if (flags & SVGA_RELOC_READ)
f |= PB_USAGE_GPU_READ;