From e82fa96d196ca141e1fd6c215b43219695931684 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 22 Jun 2016 17:18:17 -0600 Subject: svga: minor code refactor for svga_buffer_upload_command() Put the HBS code into a separate function. Reviewed-by: Charmaine Lee --- .../drivers/svga/svga_resource_buffer_upload.c | 26 +++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index 1121b780af1..a89225ded83 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -223,6 +223,7 @@ svga_buffer_upload_gb_command(struct svga_context *svga, struct pipe_resource *dummy; unsigned i; + assert(svga_have_gb_objects(svga)); assert(numBoxes); assert(sbuf->dma.updates == NULL); @@ -318,11 +319,13 @@ svga_buffer_upload_gb_command(struct svga_context *svga, /** - * Variant of SVGA3D_BufferDMA which leaves the copy box temporarily in blank. + * Issue DMA commands to transfer guest memory to the host. + * Note that the memory segments (offset, size) will be patched in + * later in the svga_buffer_upload_flush() function. */ static enum pipe_error -svga_buffer_upload_command(struct svga_context *svga, - struct svga_buffer *sbuf) +svga_buffer_upload_hb_command(struct svga_context *svga, + struct svga_buffer *sbuf) { struct svga_winsys_context *swc = svga->swc; struct svga_winsys_buffer *guest = sbuf->hwbuf; @@ -336,8 +339,7 @@ svga_buffer_upload_command(struct svga_context *svga, unsigned surface_flags; struct pipe_resource *dummy; - if (svga_have_gb_objects(svga)) - return svga_buffer_upload_gb_command(svga, sbuf); + assert(!svga_have_gb_objects(svga)); if (transfer == SVGA3D_WRITE_HOST_VRAM) { region_flags = SVGA_RELOC_READ; @@ -393,6 +395,20 @@ svga_buffer_upload_command(struct svga_context *svga, } +/** + * Issue commands to transfer guest memory to the host. + */ +static enum pipe_error +svga_buffer_upload_command(struct svga_context *svga, struct svga_buffer *sbuf) +{ + if (svga_have_gb_objects(svga)) { + return svga_buffer_upload_gb_command(svga, sbuf); + } else { + return svga_buffer_upload_hb_command(svga, sbuf); + } +} + + /** * Patch up the upload DMA command reserved by svga_buffer_upload_command * with the final ranges. -- cgit v1.2.3