X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;ds=inline;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_resource_buffer.h;h=05025e963bcd6b2fc068bc386e189ad4b6742210;hb=0baa372b6fa4b21e0214e8f208fe08b2ab2b0ecc;hp=da85f1a002e662bd3b9a8721cc3dfe5be05bac8e;hpb=7435c043988dd83b430f3d3a7ca5a5a1b2f30d61;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_resource_buffer.h b/src/gallium/drivers/svga/svga_resource_buffer.h index da85f1a002e..05025e963bc 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer.h +++ b/src/gallium/drivers/svga/svga_resource_buffer.h @@ -31,9 +31,10 @@ #include "pipe/p_state.h" #include "util/u_transfer.h" -#include "util/u_double_list.h" - #include "svga_screen_cache.h" +#include "svga_screen.h" +#include "svga_cmd.h" +#include "svga_context.h" /** @@ -42,7 +43,6 @@ #define SVGA_BUFFER_MAX_RANGES 32 -struct svga_screen; struct svga_context; struct svga_winsys_buffer; struct svga_winsys_surface; @@ -56,6 +56,7 @@ struct svga_buffer_range unsigned end; }; +struct svga_3d_update_gb_image; /** * SVGA pipe buffer. @@ -64,6 +65,9 @@ struct svga_buffer { struct u_resource b; + /** This is a superset of b.b.bind */ + unsigned bind_flags; + /** * Regular (non DMA'able) memory. * @@ -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. */ @@ -178,17 +188,30 @@ struct svga_buffer * a context. It is only valid if the dma.pending is set above. */ struct list_head head; + + unsigned size; /**< Approximate size in bytes */ + + boolean dirty; /**< Need to do a readback before mapping? */ + + /** In some cases we try to keep the results of the translate_indices() + * function from svga_draw_elements.c + */ + struct { + enum pipe_prim_type orig_prim, new_prim; + struct pipe_resource *buffer; + unsigned index_size; + unsigned offset; /**< first index */ + unsigned count; /**< num indices */ + } translated_indices; }; -static INLINE struct svga_buffer * -svga_buffer(struct pipe_resource *buffer) +static inline struct svga_buffer * +svga_buffer(struct pipe_resource *resource) { - if (buffer) { - assert(((struct svga_buffer *)buffer)->b.vtbl == &svga_buffer_vtbl); - return (struct svga_buffer *)buffer; - } - return NULL; + struct svga_buffer *buf = (struct svga_buffer *) resource; + assert(buf == NULL || buf->b.vtbl == &svga_buffer_vtbl); + return buf; } @@ -196,7 +219,7 @@ svga_buffer(struct pipe_resource *buffer) * Returns TRUE for user buffers. We may * decide to use an alternate upload path for these buffers. */ -static INLINE boolean +static inline boolean svga_buffer_is_user_buffer( struct pipe_resource *buffer ) { if (buffer) { @@ -206,7 +229,77 @@ 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. + * \param flags bitmask of PIPE_TRANSFER_* flags + */ +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); + + svga->hud.num_buffers_mapped++; + + 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 *