<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0);">
For the series,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0);">
Reviewed-by: Neha Bhende <bhenden@vmware.com></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 10pt; color: rgb(0, 0, 0);">
<br>
</div>
<div id="signature">
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; background-color:#FFFFFF; font-family:Calibri,Arial,Helvetica,sans-serif">
<p style="margin-top: 0px; margin-bottom: 0px;"><span style="font-size:11pt; font-family:Calibri,Helvetica,sans-serif"></span><span style="font-size:10pt; font-family:Calibri,Helvetica,sans-serif">Regards,</span></p>
<span style="font-size:10pt"></span><span style="font-size:11pt; font-family:Calibri,Helvetica,sans-serif"></span><span style="font-size:10pt"></span>
<p style="margin-top: 0px; margin-bottom: 0px;"><span style="font-size:10pt; font-family:Calibri,Helvetica,sans-serif">Neha</span><br>
</p>
</div>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Brian Paul <brianp@vmware.com><br>
<b>Sent:</b> Tuesday, March 5, 2019 7:48 PM<br>
<b>To:</b> mesa-dev@lists.freedesktop.org<br>
<b>Cc:</b> Neha Bhende; Deepak Singh Rawat; Thomas Hellstrom<br>
<b>Subject:</b> [PATCH 3/3] winsys/svga: use new pb_usage_flags enum type</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">And add a comment that we're implicitly converting PIPE_TRANSFER_<br>
flags to PB_USAGE_ flags in one place.  And statically assert that<br>
the enum values match.<br>
---<br>
 src/gallium/winsys/svga/drm/vmw_buffer.c  | 27 +++++++++++++++++++++++----<br>
 src/gallium/winsys/svga/drm/vmw_buffer.h  |  1 +<br>
 src/gallium/winsys/svga/drm/vmw_context.c |  4 ++--<br>
 3 files changed, 26 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.c b/src/gallium/winsys/svga/drm/vmw_buffer.c<br>
index 3ac80c7..91b5b25 100644<br>
--- a/src/gallium/winsys/svga/drm/vmw_buffer.c<br>
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.c<br>
@@ -90,6 +90,11 @@ static inline struct vmw_gmr_bufmgr *<br>
 vmw_gmr_bufmgr(struct pb_manager *mgr)<br>
 {<br>
    assert(mgr);<br>
+<br>
+   /* Make sure our extra flags don't collide with pipebuffer's flags */<br>
+   STATIC_ASSERT((VMW_BUFFER_USAGE_SHARED & PB_USAGE_ALL) == 0);<br>
+   STATIC_ASSERT((VMW_BUFFER_USAGE_SYNC & PB_USAGE_ALL) == 0);<br>
+<br>
    return (struct vmw_gmr_bufmgr *)mgr;<br>
 }<br>
 <br>
@@ -109,7 +114,7 @@ vmw_gmr_buffer_destroy(struct pb_buffer *_buf)<br>
 <br>
 static void *<br>
 vmw_gmr_buffer_map(struct pb_buffer *_buf,<br>
-                   unsigned flags,<br>
+                   enum pb_usage_flags flags,<br>
                    void *flush_ctx)<br>
 {<br>
    struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);<br>
@@ -140,7 +145,7 @@ static void<br>
 vmw_gmr_buffer_unmap(struct pb_buffer *_buf)<br>
 {<br>
    struct vmw_gmr_buffer *buf = vmw_gmr_buffer(_buf);<br>
-   unsigned flags = buf->map_flags;<br>
+   enum pb_usage_flags flags = buf->map_flags;<br>
 <br>
    if ((_buf->usage & VMW_BUFFER_USAGE_SYNC) &&<br>
        !(flags & PB_USAGE_UNSYNCHRONIZED)) {<br>
@@ -164,7 +169,7 @@ vmw_gmr_buffer_get_base_buffer(struct pb_buffer *buf,<br>
 static enum pipe_error<br>
 vmw_gmr_buffer_validate( struct pb_buffer *_buf, <br>
                          struct pb_validate *vl,<br>
-                         unsigned flags )<br>
+                         enum pb_usage_flags flags )<br>
 {<br>
    /* Always pinned */<br>
    return PIPE_OK;<br>
@@ -338,7 +343,7 @@ vmw_svga_winsys_buffer_destroy(struct svga_winsys_screen *sws,<br>
 void *<br>
 vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,<br>
                            struct svga_winsys_buffer *buf,<br>
-                           unsigned flags)<br>
+                           enum pipe_transfer_usage flags)<br>
 {<br>
    void *map;<br>
 <br>
@@ -346,6 +351,20 @@ vmw_svga_winsys_buffer_map(struct svga_winsys_screen *sws,<br>
    if (flags & PIPE_TRANSFER_UNSYNCHRONIZED)<br>
       flags &= ~PIPE_TRANSFER_DONTBLOCK;<br>
 <br>
+   /* NOTE: we're passing PIPE_TRANSFER_x flags instead of<br>
+    * PB_USAGE_x flags here.  We should probably fix that.<br>
+    */<br>
+   STATIC_ASSERT((unsigned) PB_USAGE_CPU_READ ==<br>
+                 (unsigned) PIPE_TRANSFER_READ);<br>
+   STATIC_ASSERT((unsigned) PB_USAGE_CPU_WRITE ==<br>
+                 (unsigned) PIPE_TRANSFER_WRITE);<br>
+   STATIC_ASSERT((unsigned) PB_USAGE_GPU_READ ==<br>
+                 (unsigned) PIPE_TRANSFER_MAP_DIRECTLY);<br>
+   STATIC_ASSERT((unsigned) PB_USAGE_DONTBLOCK ==<br>
+                 (unsigned) PIPE_TRANSFER_DONTBLOCK);<br>
+   STATIC_ASSERT((unsigned) PB_USAGE_UNSYNCHRONIZED ==<br>
+                 (unsigned) PIPE_TRANSFER_UNSYNCHRONIZED);<br>
+<br>
    map = pb_map(vmw_pb_buffer(buf), flags, NULL);<br>
 <br>
 #ifdef DEBUG<br>
diff --git a/src/gallium/winsys/svga/drm/vmw_buffer.h b/src/gallium/winsys/svga/drm/vmw_buffer.h<br>
index 6e1151e..8ed56d4 100644<br>
--- a/src/gallium/winsys/svga/drm/vmw_buffer.h<br>
+++ b/src/gallium/winsys/svga/drm/vmw_buffer.h<br>
@@ -33,6 +33,7 @@<br>
 #include "util/u_debug_flush.h"<br>
 <br>
 <br>
+/* These extra flags are used wherever the pb_usage_flags enum type is used */<br>
 #define VMW_BUFFER_USAGE_SHARED    (1 << 20)<br>
 #define VMW_BUFFER_USAGE_SYNC      (1 << 21)<br>
 <br>
diff --git a/src/gallium/winsys/svga/drm/vmw_context.c b/src/gallium/winsys/svga/drm/vmw_context.c<br>
index c0ee833..59963ff 100644<br>
--- a/src/gallium/winsys/svga/drm/vmw_context.c<br>
+++ b/src/gallium/winsys/svga/drm/vmw_context.c<br>
@@ -161,10 +161,10 @@ vmw_svga_winsys_context(struct svga_winsys_context *swc)<br>
 }<br>
 <br>
 <br>
-static inline unsigned<br>
+static inline enum pb_usage_flags<br>
 vmw_translate_to_pb_flags(unsigned flags)<br>
 {<br>
-   unsigned f = 0;<br>
+   enum pb_usage_flags f = 0;<br>
    if (flags & SVGA_RELOC_READ)<br>
       f |= PB_USAGE_GPU_READ;<br>
 <br>
-- <br>
1.8.5.6<br>
<br>
</div>
</span></font></div>
</body>
</html>