summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/swr_screen.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_screen.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_screen.cpp')
-rw-r--r--src/gallium/drivers/swr/swr_screen.cpp35
1 files changed, 17 insertions, 18 deletions
diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp
index 7a46d092f41..a9905d79b4e 100644
--- a/src/gallium/drivers/swr/swr_screen.cpp
+++ b/src/gallium/drivers/swr/swr_screen.cpp
@@ -869,29 +869,28 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt)
struct swr_resource *spr = swr_resource(pt);
struct pipe_context *pipe = screen->pipe;
- /* Only wait on fence if the resource is being used */
- if (pipe && spr->status) {
- /* But, if there's no fence pending, submit one.
- * XXX: Remove once draw timestamps are implmented. */
- if (!swr_is_fence_pending(screen->flush_fence))
- swr_fence_submit(swr_context(pipe), screen->flush_fence);
-
+ if (spr->display_target) {
+ /* If resource is display target, winsys manages the buffer and will
+ * free it on displaytarget_destroy. */
swr_fence_finish(p_screen, NULL, screen->flush_fence, 0);
- swr_resource_unused(pt);
- }
- /*
- * Free resource primary surface. If resource is display target, winsys
- * manages the buffer and will free it on displaytarget_destroy.
- */
- if (spr->display_target) {
- /* display target */
struct sw_winsys *winsys = screen->winsys;
winsys->displaytarget_destroy(winsys, spr->display_target);
- } else
- AlignedFree(spr->swr.pBaseAddress);
- AlignedFree(spr->secondary.pBaseAddress);
+ } else {
+ /* For regular resources, if the resource is being used, defer deletion
+ * (use aligned-free) */
+ if (pipe && spr->status) {
+ swr_resource_unused(pt);
+ swr_fence_work_free(screen->flush_fence,
+ spr->swr.pBaseAddress, true);
+ swr_fence_work_free(screen->flush_fence,
+ spr->secondary.pBaseAddress, true);
+ } else {
+ AlignedFree(spr->swr.pBaseAddress);
+ AlignedFree(spr->secondary.pBaseAddress);
+ }
+ }
FREE(spr);
}