Mesa (master): zink: hammer in an explicit wait when retrieving buffer contents for reading
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 22 13:38:24 UTC 2020
Module: Mesa
Branch: master
Commit: 0d2ec80dea8adf3089f187f8c0e9bdbcb135b4f2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0d2ec80dea8adf3089f187f8c0e9bdbcb135b4f2
Author: Erik Faye-Lund <kusmabite at gmail.com>
Date: Wed May 20 09:59:26 2020 -0400
zink: hammer in an explicit wait when retrieving buffer contents for reading
this ensures that the buffer returned is synchronized as expected, though
it incurs a significant performance hit and will hopefully be improved in future
patches
Reviewed-by: Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5120>
---
src/gallium/drivers/zink/zink_resource.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c
index b1ab56699f6..a52d8bb6c70 100644
--- a/src/gallium/drivers/zink/zink_resource.c
+++ b/src/gallium/drivers/zink/zink_resource.c
@@ -434,6 +434,21 @@ zink_transfer_map(struct pipe_context *pctx,
void *ptr;
if (pres->target == PIPE_BUFFER) {
+ if (usage & PIPE_TRANSFER_READ) {
+ /* need to wait for rendering to finish
+ * TODO: optimize/fix this to be much less obtrusive
+ * mesa/mesa#2966
+ */
+ struct pipe_fence_handle *fence = NULL;
+ pctx->flush(pctx, &fence, PIPE_FLUSH_HINT_FINISH);
+ if (fence) {
+ pctx->screen->fence_finish(pctx->screen, NULL, fence,
+ PIPE_TIMEOUT_INFINITE);
+ pctx->screen->fence_reference(pctx->screen, &fence, NULL);
+ }
+ }
+
+
VkResult result = vkMapMemory(screen->dev, res->mem, res->offset, res->size, 0, &ptr);
if (result != VK_SUCCESS)
return NULL;
More information about the mesa-commit
mailing list