<div dir="ltr">Reviewed-by: Christoph Brill <<a href="mailto:egore911@gmail.com">egore911@gmail.com</a>></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/11/29 Marek Olšák <span dir="ltr"><<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>><br>
<br>
---<br>
src/gallium/drivers/radeon/Makefile.sources | 1 +<br>
src/gallium/drivers/radeon/r600_buffer.c | 133 ++++++++++++++++++++++++++<br>
src/gallium/drivers/radeon/r600_pipe_common.c | 106 --------------------<br>
3 files changed, 134 insertions(+), 106 deletions(-)<br>
create mode 100644 src/gallium/drivers/radeon/r600_buffer.c<br>
<br>
diff --git a/src/gallium/drivers/radeon/Makefile.sources b/src/gallium/drivers/radeon/Makefile.sources<br>
index 894f22a..bd06ed8 100644<br>
--- a/src/gallium/drivers/radeon/Makefile.sources<br>
+++ b/src/gallium/drivers/radeon/Makefile.sources<br>
@@ -1,4 +1,5 @@<br>
C_SOURCES := \<br>
+ r600_buffer.c \<br>
r600_pipe_common.c \<br>
r600_streamout.c \<br>
r600_texture.c \<br>
diff --git a/src/gallium/drivers/radeon/r600_buffer.c b/src/gallium/drivers/radeon/r600_buffer.c<br>
new file mode 100644<br>
index 0000000..13d11bd<br>
--- /dev/null<br>
+++ b/src/gallium/drivers/radeon/r600_buffer.c<br>
@@ -0,0 +1,133 @@<br>
+/*<br>
+ * Copyright 2013 Advanced Micro Devices, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * on the rights to use, copy, modify, merge, publish, distribute, sub<br>
+ * license, and/or sell copies of the Software, and to permit persons to whom<br>
+ * the Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL<br>
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,<br>
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR<br>
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE<br>
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.<br>
+ *<br>
+ * Authors:<br>
+ * Marek Olšák<br>
+ */<br>
+<br>
+#include "r600_cs.h"<br>
+<br>
+void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,<br>
+ struct r600_resource *resource,<br>
+ unsigned usage)<br>
+{<br>
+ enum radeon_bo_usage rusage = RADEON_USAGE_READWRITE;<br>
+<br>
+ if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) {<br>
+ return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);<br>
+ }<br>
+<br>
+ if (!(usage & PIPE_TRANSFER_WRITE)) {<br>
+ /* have to wait for the last write */<br>
+ rusage = RADEON_USAGE_WRITE;<br>
+ }<br>
+<br>
+ if (ctx->rings.gfx.cs->cdw &&<br>
+ ctx->ws->cs_is_buffer_referenced(ctx->rings.gfx.cs,<br>
+ resource->cs_buf, rusage)) {<br>
+ if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
+ ctx->rings.gfx.flush(ctx, RADEON_FLUSH_ASYNC);<br>
+ return NULL;<br>
+ } else {<br>
+ ctx->rings.gfx.flush(ctx, 0);<br>
+ }<br>
+ }<br>
+ if (ctx->rings.dma.cs &&<br>
+ ctx->rings.dma.cs->cdw &&<br>
+ ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs,<br>
+ resource->cs_buf, rusage)) {<br>
+ if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
+ ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC);<br>
+ return NULL;<br>
+ } else {<br>
+ ctx->rings.dma.flush(ctx, 0);<br>
+ }<br>
+ }<br>
+<br>
+ if (ctx->ws->buffer_is_busy(resource->buf, rusage)) {<br>
+ if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
+ return NULL;<br>
+ } else {<br>
+ /* We will be wait for the GPU. Wait for any offloaded<br>
+ * CS flush to complete to avoid busy-waiting in the winsys. */<br>
+ ctx->ws->cs_sync_flush(ctx->rings.gfx.cs);<br>
+ if (ctx->rings.dma.cs)<br>
+ ctx->ws->cs_sync_flush(ctx->rings.dma.cs);<br>
+ }<br>
+ }<br>
+<br>
+ return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);<br>
+}<br>
+<br>
+bool r600_init_resource(struct r600_common_screen *rscreen,<br>
+ struct r600_resource *res,<br>
+ unsigned size, unsigned alignment,<br>
+ bool use_reusable_pool, unsigned usage)<br>
+{<br>
+ uint32_t initial_domain, domains;<br>
+<br>
+ switch(usage) {<br>
+ case PIPE_USAGE_STAGING:<br>
+ /* Staging resources participate in transfers, i.e. are used<br>
+ * for uploads and downloads from regular resources.<br>
+ * We generate them internally for some transfers.<br>
+ */<br>
+ initial_domain = RADEON_DOMAIN_GTT;<br>
+ domains = RADEON_DOMAIN_GTT;<br>
+ break;<br>
+ case PIPE_USAGE_DYNAMIC:<br>
+ case PIPE_USAGE_STREAM:<br>
+ /* Default to GTT, but allow the memory manager to move it to VRAM. */<br>
+ initial_domain = RADEON_DOMAIN_GTT;<br>
+ domains = RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM;<br>
+ break;<br>
+ case PIPE_USAGE_DEFAULT:<br>
+ case PIPE_USAGE_STATIC:<br>
+ case PIPE_USAGE_IMMUTABLE:<br>
+ default:<br>
+ /* Don't list GTT here, because the memory manager would put some<br>
+ * resources to GTT no matter what the initial domain is.<br>
+ * Not listing GTT in the domains improves performance a lot. */<br>
+ initial_domain = RADEON_DOMAIN_VRAM;<br>
+ domains = RADEON_DOMAIN_VRAM;<br>
+ break;<br>
+ }<br>
+<br>
+ res->buf = rscreen->ws->buffer_create(rscreen->ws, size, alignment,<br>
+ use_reusable_pool,<br>
+ initial_domain);<br>
+ if (!res->buf) {<br>
+ return false;<br>
+ }<br>
+<br>
+ res->cs_buf = rscreen->ws->buffer_get_cs_handle(res->buf);<br>
+ res->domains = domains;<br>
+ util_range_set_empty(&res->valid_buffer_range);<br>
+<br>
+ if (rscreen->debug_flags & DBG_VM && res->b.b.target == PIPE_BUFFER) {<br>
+ fprintf(stderr, "VM start=0x%llX end=0x%llX | Buffer %u bytes\n",<br>
+ r600_resource_va(&rscreen->b, &res->b.b),<br>
+ r600_resource_va(&rscreen->b, &res->b.b) + res->buf->size,<br>
+ res->buf->size);<br>
+ }<br>
+ return true;<br>
+}<br>
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c<br>
index 5674f81..2cdca77 100644<br>
--- a/src/gallium/drivers/radeon/r600_pipe_common.c<br>
+++ b/src/gallium/drivers/radeon/r600_pipe_common.c<br>
@@ -319,109 +319,3 @@ boolean r600_rings_is_buffer_referenced(struct r600_common_context *ctx,<br>
}<br>
return FALSE;<br>
}<br>
-<br>
-void *r600_buffer_map_sync_with_rings(struct r600_common_context *ctx,<br>
- struct r600_resource *resource,<br>
- unsigned usage)<br>
-{<br>
- enum radeon_bo_usage rusage = RADEON_USAGE_READWRITE;<br>
-<br>
- if (usage & PIPE_TRANSFER_UNSYNCHRONIZED) {<br>
- return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);<br>
- }<br>
-<br>
- if (!(usage & PIPE_TRANSFER_WRITE)) {<br>
- /* have to wait for the last write */<br>
- rusage = RADEON_USAGE_WRITE;<br>
- }<br>
-<br>
- if (ctx->rings.gfx.cs->cdw &&<br>
- ctx->ws->cs_is_buffer_referenced(ctx->rings.gfx.cs,<br>
- resource->cs_buf, rusage)) {<br>
- if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
- ctx->rings.gfx.flush(ctx, RADEON_FLUSH_ASYNC);<br>
- return NULL;<br>
- } else {<br>
- ctx->rings.gfx.flush(ctx, 0);<br>
- }<br>
- }<br>
- if (ctx->rings.dma.cs &&<br>
- ctx->rings.dma.cs->cdw &&<br>
- ctx->ws->cs_is_buffer_referenced(ctx->rings.dma.cs,<br>
- resource->cs_buf, rusage)) {<br>
- if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
- ctx->rings.dma.flush(ctx, RADEON_FLUSH_ASYNC);<br>
- return NULL;<br>
- } else {<br>
- ctx->rings.dma.flush(ctx, 0);<br>
- }<br>
- }<br>
-<br>
- if (ctx->ws->buffer_is_busy(resource->buf, rusage)) {<br>
- if (usage & PIPE_TRANSFER_DONTBLOCK) {<br>
- return NULL;<br>
- } else {<br>
- /* We will be wait for the GPU. Wait for any offloaded<br>
- * CS flush to complete to avoid busy-waiting in the winsys. */<br>
- ctx->ws->cs_sync_flush(ctx->rings.gfx.cs);<br>
- if (ctx->rings.dma.cs)<br>
- ctx->ws->cs_sync_flush(ctx->rings.dma.cs);<br>
- }<br>
- }<br>
-<br>
- return ctx->ws->buffer_map(resource->cs_buf, NULL, usage);<br>
-}<br>
-<br>
-bool r600_init_resource(struct r600_common_screen *rscreen,<br>
- struct r600_resource *res,<br>
- unsigned size, unsigned alignment,<br>
- bool use_reusable_pool, unsigned usage)<br>
-{<br>
- uint32_t initial_domain, domains;<br>
-<br>
- switch(usage) {<br>
- case PIPE_USAGE_STAGING:<br>
- /* Staging resources participate in transfers, i.e. are used<br>
- * for uploads and downloads from regular resources.<br>
- * We generate them internally for some transfers.<br>
- */<br>
- initial_domain = RADEON_DOMAIN_GTT;<br>
- domains = RADEON_DOMAIN_GTT;<br>
- break;<br>
- case PIPE_USAGE_DYNAMIC:<br>
- case PIPE_USAGE_STREAM:<br>
- /* Default to GTT, but allow the memory manager to move it to VRAM. */<br>
- initial_domain = RADEON_DOMAIN_GTT;<br>
- domains = RADEON_DOMAIN_GTT | RADEON_DOMAIN_VRAM;<br>
- break;<br>
- case PIPE_USAGE_DEFAULT:<br>
- case PIPE_USAGE_STATIC:<br>
- case PIPE_USAGE_IMMUTABLE:<br>
- default:<br>
- /* Don't list GTT here, because the memory manager would put some<br>
- * resources to GTT no matter what the initial domain is.<br>
- * Not listing GTT in the domains improves performance a lot. */<br>
- initial_domain = RADEON_DOMAIN_VRAM;<br>
- domains = RADEON_DOMAIN_VRAM;<br>
- break;<br>
- }<br>
-<br>
- res->buf = rscreen->ws->buffer_create(rscreen->ws, size, alignment,<br>
- use_reusable_pool,<br>
- initial_domain);<br>
- if (!res->buf) {<br>
- return false;<br>
- }<br>
-<br>
- res->cs_buf = rscreen->ws->buffer_get_cs_handle(res->buf);<br>
- res->domains = domains;<br>
- util_range_set_empty(&res->valid_buffer_range);<br>
-<br>
- if (rscreen->debug_flags & DBG_VM && res->b.b.target == PIPE_BUFFER) {<br>
- fprintf(stderr, "VM start=0x%llX end=0x%llX | Buffer %u bytes\n",<br>
- r600_resource_va(&rscreen->b, &res->b.b),<br>
- r600_resource_va(&rscreen->b, &res->b.b) + res->buf->size,<br>
- res->buf->size);<br>
- }<br>
- return true;<br>
-}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.2<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>