#include "util/u_double_list.h"
#include "svga_screen_cache.h"
+#include "svga_screen.h"
+#include "svga_cmd.h"
+#include "svga_context.h"
/**
unsigned end;
};
+struct svga_3d_update_gb_image;
/**
* SVGA pipe 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;
}
}
+/**
+ * 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 *