summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/svga
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/svga')
-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 *