summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/swr_scratch.cpp
diff options
context:
space:
mode:
authorBruce Cherniak <[email protected]>2016-12-12 19:24:59 -0600
committerTim Rowley <[email protected]>2016-12-16 11:29:02 -0600
commit79b66ec05e2745e5d19838dcfd83f905afa82b6c (patch)
tree5893ed8d0e3dc45248e2a4b14be64f91ec33b753 /src/gallium/drivers/swr/swr_scratch.cpp
parent3421b3f5a35f5cf29934f74c30850c4d04ba0237 (diff)
swr: Implement fence attached work queues for deferred deletion.
Work can now be added to fences and triggered by fence completion. This allows for deferred resource deletion, and other asynchronous tasks. Reviewed-by: George Kyriazis <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/swr_scratch.cpp')
-rw-r--r--src/gallium/drivers/swr/swr_scratch.cpp32
1 files changed, 11 insertions, 21 deletions
diff --git a/src/gallium/drivers/swr/swr_scratch.cpp b/src/gallium/drivers/swr/swr_scratch.cpp
index 2515c8beaf3..58d18d04fab 100644
--- a/src/gallium/drivers/swr/swr_scratch.cpp
+++ b/src/gallium/drivers/swr/swr_scratch.cpp
@@ -23,7 +23,9 @@
#include "util/u_memory.h"
#include "swr_context.h"
+#include "swr_screen.h"
#include "swr_scratch.h"
+#include "swr_fence_work.h"
#include "api.h"
@@ -46,18 +48,18 @@ swr_copy_to_scratch_space(struct swr_context *ctx,
/* Need to grow space */
if (max_size_in_flight > space->current_size) {
- /* Must idle the pipeline, this is infrequent */
- SwrWaitForIdle(ctx->swrContext);
-
space->current_size = max_size_in_flight;
if (space->base) {
- align_free(space->base);
+ /* defer delete, use aligned-free */
+ struct swr_screen *screen = swr_screen(ctx->pipe.screen);
+ swr_fence_work_free(screen->flush_fence, space->base, true);
space->base = NULL;
}
if (!space->base) {
- space->base = (uint8_t *)align_malloc(space->current_size, 4);
+ space->base = (uint8_t *)AlignedMalloc(space->current_size,
+ sizeof(void *));
space->head = (void *)space->base;
}
}
@@ -65,14 +67,6 @@ swr_copy_to_scratch_space(struct swr_context *ctx,
/* Wrap */
if (((uint8_t *)space->head + size)
>= ((uint8_t *)space->base + space->current_size)) {
- /*
- * TODO XXX: Should add a fence on wrap. Assumption is that
- * current_space >> size, and there are at least MAX_DRAWS_IN_FLIGHT
- * draws in scratch. So fence would always be met on wrap. A fence
- * would ensure that first frame in buffer is done before wrapping.
- * If fence ever needs to be waited on, can increase buffer size.
- * So far in testing, this hasn't been necessary.
- */
space->head = space->base;
}
@@ -103,14 +97,10 @@ swr_destroy_scratch_buffers(struct swr_context *ctx)
struct swr_scratch_buffers *scratch = ctx->scratch;
if (scratch) {
- if (scratch->vs_constants.base)
- align_free(scratch->vs_constants.base);
- if (scratch->fs_constants.base)
- align_free(scratch->fs_constants.base);
- if (scratch->vertex_buffer.base)
- align_free(scratch->vertex_buffer.base);
- if (scratch->index_buffer.base)
- align_free(scratch->index_buffer.base);
+ AlignedFree(scratch->vs_constants.base);
+ AlignedFree(scratch->fs_constants.base);
+ AlignedFree(scratch->vertex_buffer.base);
+ AlignedFree(scratch->index_buffer.base);
FREE(scratch);
}
}