summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2014-02-08 09:51:14 -0800
committerBrian Paul <brianp@vmware.com>2014-02-14 08:21:44 -0700
commite0a6fb09bdfde40253b924b6c9d1fdf3f16fed21 (patch)
tree44730f826df5a8791954d28a3ca8d47bef446838 /src/gallium/drivers
parent6476bcbc5005b76e1494a201f92f3c76bd8e9727 (diff)
svga: add new helper functions for GBS buffers
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/svga/svga_resource_buffer.h76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h
index b431d7b5968..36467cfdfdf 100644
--- a/src/gallium/drivers/svga/svga_resource_buffer.h
+++ b/src/gallium/drivers/svga/svga_resource_buffer.h
@@ -34,6 +34,9 @@
#include "util/u_double_list.h"
#include "svga_screen_cache.h"
+#include "svga_screen.h"
+#include "svga_cmd.h"
+#include "svga_context.h"
/**
@@ -55,6 +58,7 @@ struct svga_buffer_range
unsigned end;
};
+struct svga_3d_update_gb_image;
/**
* SVGA pipe buffer.
@@ -167,6 +171,12 @@ struct svga_buffer
SVGA3dCopyBox *boxes;
/**
+ * Pointer to the sequence of update commands
+ * *inside* the command buffer.
+ */
+ struct svga_3d_update_gb_image *updates;
+
+ /**
* Context that has the pending DMA to this buffer.
*/
struct svga_context *svga;
@@ -207,7 +217,73 @@ svga_buffer_is_user_buffer( struct pipe_resource *buffer )
}
}
+/**
+ * Returns a pointer to a struct svga_winsys_screen given a
+ * struct svga_buffer.
+ */
+static INLINE struct svga_winsys_screen *
+svga_buffer_winsys_screen(struct svga_buffer *sbuf)
+{
+ return svga_screen(sbuf->b.b.screen)->sws;
+}
+
+
+/**
+ * Returns whether a buffer has hardware storage that is
+ * visible to the GPU.
+ */
+static INLINE boolean
+svga_buffer_has_hw_storage(struct svga_buffer *sbuf)
+{
+ if (svga_buffer_winsys_screen(sbuf)->have_gb_objects)
+ return (sbuf->handle ? TRUE : FALSE);
+ else
+ return (sbuf->hwbuf ? TRUE : FALSE);
+}
+
+/**
+ * Map the hardware storage of a buffer.
+ */
+static INLINE void *
+svga_buffer_hw_storage_map(struct svga_context *svga,
+ struct svga_buffer *sbuf,
+ unsigned flags, boolean *retry)
+{
+ struct svga_winsys_screen *sws = svga_buffer_winsys_screen(sbuf);
+ if (sws->have_gb_objects) {
+ return svga->swc->surface_map(svga->swc, sbuf->handle, flags, retry);
+ } else {
+ *retry = FALSE;
+ return sws->buffer_map(sws, sbuf->hwbuf, flags);
+ }
+}
+/**
+ * Unmap the hardware storage of a buffer.
+ */
+static INLINE void
+svga_buffer_hw_storage_unmap(struct svga_context *svga,
+ struct svga_buffer *sbuf)
+{
+ struct svga_winsys_screen *sws = svga_buffer_winsys_screen(sbuf);
+
+ if (sws->have_gb_objects) {
+ struct svga_winsys_context *swc = svga->swc;
+ boolean rebind;
+ swc->surface_unmap(swc, sbuf->handle, &rebind);
+ if (rebind) {
+ enum pipe_error ret;
+ ret = SVGA3D_BindGBSurface(swc, sbuf->handle);
+ if (ret != PIPE_OK) {
+ /* flush and retry */
+ svga_context_flush(svga, NULL);
+ ret = SVGA3D_BindGBSurface(swc, sbuf->handle);
+ assert(ret == PIPE_OK);
+ }
+ }
+ } else
+ sws->buffer_unmap(sws, sbuf->hwbuf);
+}
struct pipe_resource *