From: Brian Paul Date: Sat, 7 Jan 2012 21:16:27 +0000 (-0700) Subject: svga: fix assorted whitespace issues, add copyright comment X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=59d2c4f8e5a00133c093137b2f4836313f633d60;p=mesa.git svga: fix assorted whitespace issues, add copyright comment --- diff --git a/src/gallium/drivers/svga/svga_resource.c b/src/gallium/drivers/svga/svga_resource.c index 6e0622a312b..bb6236dce67 100644 --- a/src/gallium/drivers/svga/svga_resource.c +++ b/src/gallium/drivers/svga/svga_resource.c @@ -1,3 +1,28 @@ +/********************************************************** + * Copyright 2008-2012 VMware, Inc. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, copy, + * modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + **********************************************************/ + #include "util/u_debug.h" #include "svga_resource.h" @@ -9,19 +34,19 @@ static struct pipe_resource * svga_resource_create(struct pipe_screen *screen, - const struct pipe_resource *template) + const struct pipe_resource *template) { if (template->target == PIPE_BUFFER) return svga_buffer_create(screen, template); else return svga_texture_create(screen, template); - } + static struct pipe_resource * svga_resource_from_handle(struct pipe_screen * screen, - const struct pipe_resource *template, - struct winsys_handle *whandle) + const struct pipe_resource *template, + struct winsys_handle *whandle) { if (template->target == PIPE_BUFFER) return NULL; @@ -51,6 +76,3 @@ svga_init_screen_resource_functions(struct svga_screen *is) is->screen.resource_destroy = u_resource_destroy_vtbl; is->screen.user_buffer_create = svga_user_buffer_create; } - - - diff --git a/src/gallium/drivers/svga/svga_resource_buffer_upload.c b/src/gallium/drivers/svga/svga_resource_buffer_upload.c index f4a96cba349..e5273009d41 100644 --- a/src/gallium/drivers/svga/svga_resource_buffer_upload.c +++ b/src/gallium/drivers/svga/svga_resource_buffer_upload.c @@ -49,25 +49,25 @@ */ struct svga_winsys_buffer * svga_winsys_buffer_create( struct svga_context *svga, - unsigned alignment, + unsigned alignment, unsigned usage, unsigned size ) { struct svga_screen *svgascreen = svga_screen(svga->pipe.screen); struct svga_winsys_screen *sws = svgascreen->sws; struct svga_winsys_buffer *buf; - + /* Just try */ buf = sws->buffer_create(sws, alignment, usage, size); if (!buf) { SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "flushing context to find %d bytes GMR\n", - size); - + size); + /* Try flushing all pending DMAs */ svga_context_flush(svga, NULL); buf = sws->buffer_create(sws, alignment, usage, size); } - + return buf; } @@ -79,7 +79,7 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf) assert(!sbuf->map.count); assert(sbuf->hwbuf); - if(sbuf->hwbuf) { + if (sbuf->hwbuf) { sws->buffer_destroy(sws, sbuf->hwbuf); sbuf->hwbuf = NULL; } @@ -88,8 +88,8 @@ svga_buffer_destroy_hw_storage(struct svga_screen *ss, struct svga_buffer *sbuf) /** - * Allocate DMA'ble storage for the buffer. - * + * Allocate DMA'ble storage for the buffer. + * * Called before mapping a buffer. */ enum pipe_error @@ -98,19 +98,19 @@ svga_buffer_create_hw_storage(struct svga_screen *ss, { assert(!sbuf->user); - if(!sbuf->hwbuf) { + if (!sbuf->hwbuf) { struct svga_winsys_screen *sws = ss->sws; unsigned alignment = 16; unsigned usage = 0; unsigned size = sbuf->b.b.width0; - + sbuf->hwbuf = sws->buffer_create(sws, alignment, usage, size); - if(!sbuf->hwbuf) + if (!sbuf->hwbuf) return PIPE_ERROR_OUT_OF_MEMORY; - + assert(!sbuf->dma.pending); } - + return PIPE_OK; } @@ -122,29 +122,29 @@ svga_buffer_create_host_surface(struct svga_screen *ss, { assert(!sbuf->user); - if(!sbuf->handle) { + if (!sbuf->handle) { sbuf->key.flags = 0; - + sbuf->key.format = SVGA3D_BUFFER; - if(sbuf->b.b.bind & PIPE_BIND_VERTEX_BUFFER) + if (sbuf->b.b.bind & PIPE_BIND_VERTEX_BUFFER) sbuf->key.flags |= SVGA3D_SURFACE_HINT_VERTEXBUFFER; - if(sbuf->b.b.bind & PIPE_BIND_INDEX_BUFFER) + if (sbuf->b.b.bind & PIPE_BIND_INDEX_BUFFER) sbuf->key.flags |= SVGA3D_SURFACE_HINT_INDEXBUFFER; - + sbuf->key.size.width = sbuf->b.b.width0; sbuf->key.size.height = 1; sbuf->key.size.depth = 1; - + sbuf->key.numFaces = 1; sbuf->key.numMipLevels = 1; sbuf->key.cachable = 1; - + SVGA_DBG(DEBUG_DMA, "surface_create for buffer sz %d\n", sbuf->b.b.width0); sbuf->handle = svga_screen_surface_create(ss, &sbuf->key); - if(!sbuf->handle) + if (!sbuf->handle) return PIPE_ERROR_OUT_OF_MEMORY; - + /* Always set the discard flag on the first time the buffer is written * as svga_screen_surface_create might have passed a recycled host * buffer. @@ -153,20 +153,20 @@ svga_buffer_create_host_surface(struct svga_screen *ss, SVGA_DBG(DEBUG_DMA, " --> got sid %p sz %d (buffer)\n", sbuf->handle, sbuf->b.b.width0); } - + return PIPE_OK; -} +} void svga_buffer_destroy_host_surface(struct svga_screen *ss, struct svga_buffer *sbuf) { - if(sbuf->handle) { + if (sbuf->handle) { SVGA_DBG(DEBUG_DMA, " ungrab sid %p sz %d\n", sbuf->handle, sbuf->b.b.width0); svga_screen_surface_destroy(ss, &sbuf->key, &sbuf->handle); } -} +} /** @@ -188,11 +188,11 @@ svga_buffer_upload_command(struct svga_context *svga, unsigned surface_flags; struct pipe_resource *dummy; - if(transfer == SVGA3D_WRITE_HOST_VRAM) { + if (transfer == SVGA3D_WRITE_HOST_VRAM) { region_flags = SVGA_RELOC_READ; surface_flags = SVGA_RELOC_WRITE; } - else if(transfer == SVGA3D_READ_HOST_VRAM) { + else if (transfer == SVGA3D_READ_HOST_VRAM) { region_flags = SVGA_RELOC_WRITE; surface_flags = SVGA_RELOC_READ; } @@ -207,7 +207,7 @@ svga_buffer_upload_command(struct svga_context *svga, SVGA_3D_CMD_SURFACE_DMA, sizeof *cmd + numBoxes * sizeof *boxes + sizeof *pSuffix, 2); - if(!cmd) + if (!cmd) return PIPE_ERROR_OUT_OF_MEMORY; swc->region_relocation(swc, &cmd->guest.ptr, guest, 0, region_flags); @@ -255,12 +255,12 @@ svga_buffer_upload_flush(struct svga_context *svga, return; } - assert(sbuf->handle); + assert(sbuf->handle); assert(sbuf->hwbuf); assert(sbuf->map.num_ranges); assert(sbuf->dma.svga == svga); assert(sbuf->dma.boxes); - + /* * Patch the DMA command with the final copy box. */ @@ -268,7 +268,7 @@ svga_buffer_upload_flush(struct svga_context *svga, SVGA_DBG(DEBUG_DMA, "dma to sid %p\n", sbuf->handle); boxes = sbuf->dma.boxes; - for(i = 0; i < sbuf->map.num_ranges; ++i) { + for (i = 0; i < sbuf->map.num_ranges; ++i) { SVGA_DBG(DEBUG_DMA, " bytes %u - %u\n", sbuf->map.ranges[i].start, sbuf->map.ranges[i].end); @@ -288,7 +288,7 @@ svga_buffer_upload_flush(struct svga_context *svga, assert(sbuf->head.prev && sbuf->head.next); LIST_DEL(&sbuf->head); #ifdef DEBUG - sbuf->head.next = sbuf->head.prev = NULL; + sbuf->head.next = sbuf->head.prev = NULL; #endif sbuf->dma.pending = FALSE; sbuf->dma.flags.discard = FALSE; @@ -308,8 +308,9 @@ svga_buffer_upload_flush(struct svga_context *svga, * * This function only notes the range down. It doesn't actually emit a DMA * upload command. That only happens when a context tries to refer to this - * buffer, and the DMA upload command is added to that context's command buffer. - * + * buffer, and the DMA upload command is added to that context's command + * buffer. + * * We try to lump as many contiguous DMA transfers together as possible. */ void @@ -322,7 +323,7 @@ svga_buffer_add_range(struct svga_buffer *sbuf, unsigned nearest_dist; assert(end > start); - + if (sbuf->map.num_ranges < SVGA_BUFFER_MAX_RANGES) { nearest_range = sbuf->map.num_ranges; nearest_dist = ~0; @@ -335,7 +336,7 @@ svga_buffer_add_range(struct svga_buffer *sbuf, * Try to grow one of the ranges. */ - for(i = 0; i < sbuf->map.num_ranges; ++i) { + for (i = 0; i < sbuf->map.num_ranges; ++i) { int left_dist; int right_dist; int dist; @@ -413,22 +414,22 @@ static INLINE enum pipe_error svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf) { assert(!sbuf->user); - if(!sbuf->hwbuf) { + if (!sbuf->hwbuf) { enum pipe_error ret; void *map; - + assert(sbuf->swbuf); - if(!sbuf->swbuf) + if (!sbuf->swbuf) return PIPE_ERROR; - + ret = svga_buffer_create_hw_storage(ss, sbuf); - if(ret != PIPE_OK) + if (ret != PIPE_OK) return ret; pipe_mutex_lock(ss->swc_mutex); map = ss->sws->buffer_map(ss->sws, sbuf->hwbuf, PIPE_TRANSFER_WRITE); assert(map); - if(!map) { + if (!map) { pipe_mutex_unlock(ss->swc_mutex); svga_buffer_destroy_hw_storage(ss, sbuf); return PIPE_ERROR; @@ -439,17 +440,17 @@ svga_buffer_update_hw(struct svga_screen *ss, struct svga_buffer *sbuf) /* This user/malloc buffer is now indistinguishable from a gpu buffer */ assert(!sbuf->map.count); - if(!sbuf->map.count) { - if(sbuf->user) + if (!sbuf->map.count) { + if (sbuf->user) sbuf->user = FALSE; else align_free(sbuf->swbuf); sbuf->swbuf = NULL; } - + pipe_mutex_unlock(ss->swc_mutex); } - + return PIPE_OK; } @@ -511,7 +512,7 @@ svga_buffer_upload_piecewise(struct svga_screen *ss, hwbuf, sbuf->handle, SVGA3D_WRITE_HOST_VRAM, size, 0, offset, sbuf->dma.flags); - if(ret != PIPE_OK) { + if (ret != PIPE_OK) { svga_context_flush(svga, NULL); ret = SVGA3D_BufferDMA(svga->swc, hwbuf, sbuf->handle, @@ -548,17 +549,17 @@ svga_buffer_handle(struct svga_context *svga, struct svga_buffer *sbuf; enum pipe_error ret; - if(!buf) + if (!buf) return NULL; sbuf = svga_buffer(buf); - + assert(!sbuf->map.count); assert(!sbuf->user); - - if(!sbuf->handle) { + + if (!sbuf->handle) { ret = svga_buffer_create_host_surface(ss, sbuf); - if(ret != PIPE_OK) + if (ret != PIPE_OK) return NULL; } @@ -636,10 +637,10 @@ svga_context_flush_buffers(struct svga_context *svga) assert(p_atomic_read(&sbuf->b.b.reference.count) != 0); assert(sbuf->dma.pending); - + svga_buffer_upload_flush(svga, sbuf); - curr = next; + curr = next; next = curr->next; } } diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c index 4eb1068e226..d3748420c0a 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.c +++ b/src/gallium/drivers/svga/svga_resource_texture.c @@ -196,9 +196,6 @@ svga_transfer_dma(struct svga_context *svga, } - - - static boolean svga_texture_get_handle(struct pipe_screen *screen, struct pipe_resource *texture, @@ -236,11 +233,6 @@ svga_texture_destroy(struct pipe_screen *screen, } - - - - - /* XXX: Still implementing this as if it was a screen function, but * can now modify it to queue transfers on the context. */ @@ -396,9 +388,6 @@ svga_texture_transfer_destroy(struct pipe_context *pipe, } - - - struct u_resource_vtbl svga_texture_vtbl = { svga_texture_get_handle, /* get_handle */ @@ -412,8 +401,6 @@ struct u_resource_vtbl svga_texture_vtbl = }; - - struct pipe_resource * svga_texture_create(struct pipe_screen *screen, const struct pipe_resource *template) @@ -504,8 +491,6 @@ error1: } - - struct pipe_resource * svga_texture_from_handle(struct pipe_screen *screen, const struct pipe_resource *template, @@ -568,4 +553,3 @@ svga_texture_from_handle(struct pipe_screen *screen, return &tex->b.b; } -