* This file implements VkQueue, VkFence, and VkSemaphore
*/
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/eventfd.h>
+
#include "anv_private.h"
-#include "util/vk_util.h"
+#include "vk_util.h"
#include "genxml/gen7_pack.h"
memcpy(bo.map, batch->start, size);
if (!device->info.has_llc)
- anv_flush_range(bo.map, size);
+ gen_flush_range(bo.map, size);
exec_bos[0] = &bo;
exec2_objects[0].handle = bo.gem_handle;
assert(cmd_buffer->level == VK_COMMAND_BUFFER_LEVEL_PRIMARY);
assert(!anv_batch_has_error(&cmd_buffer->batch));
- result = anv_cmd_buffer_execbuf(device, cmd_buffer);
+ const VkSemaphore *in_semaphores = NULL, *out_semaphores = NULL;
+ uint32_t num_in_semaphores = 0, num_out_semaphores = 0;
+ if (j == 0) {
+ /* Only the first batch gets the in semaphores */
+ in_semaphores = pSubmits[i].pWaitSemaphores;
+ num_in_semaphores = pSubmits[i].waitSemaphoreCount;
+ }
+
+ if (j == pSubmits[i].commandBufferCount - 1) {
+ /* Only the last batch gets the out semaphores */
+ out_semaphores = pSubmits[i].pSignalSemaphores;
+ num_out_semaphores = pSubmits[i].signalSemaphoreCount;
+ }
+
+ result = anv_cmd_buffer_execbuf(device, cmd_buffer,
+ in_semaphores, num_in_semaphores,
+ out_semaphores, num_out_semaphores);
if (result != VK_SUCCESS)
goto out;
}
* VK_ERROR_DEVICE_LOST to ensure that clients do not attempt to
* submit the same job again to this device.
*/
- result = VK_ERROR_DEVICE_LOST;
+ result = vk_errorf(VK_ERROR_DEVICE_LOST, "vkQueueSubmit() failed");
device->lost = true;
/* If we return VK_ERROR_DEVICE LOST here, we need to ensure that
if (semaphore == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- /* The DRM execbuffer ioctl always execute in-oder, even between
- * different rings. As such, a dummy no-op semaphore is a perfectly
- * valid implementation.
+ /* The DRM execbuffer ioctl always execute in-oder so long as you stay
+ * on the same ring. Since we don't expose the blit engine as a DMA
+ * queue, a dummy no-op semaphore is a perfectly valid implementation.
*/
semaphore->permanent.type = ANV_SEMAPHORE_TYPE_DUMMY;
semaphore->temporary.type = ANV_SEMAPHORE_TYPE_NONE;
return VK_SUCCESS;
}
+static void
+anv_semaphore_impl_cleanup(struct anv_device *device,
+ struct anv_semaphore_impl *impl)
+{
+ switch (impl->type) {
+ case ANV_SEMAPHORE_TYPE_NONE:
+ case ANV_SEMAPHORE_TYPE_DUMMY:
+ /* Dummy. Nothing to do */
+ return;
+
+ case ANV_SEMAPHORE_TYPE_BO:
+ anv_bo_cache_release(device, &device->bo_cache, impl->bo);
+ return;
+ }
+
+ unreachable("Invalid semaphore type");
+}
+
void anv_DestroySemaphore(
VkDevice _device,
VkSemaphore _semaphore,
if (semaphore == NULL)
return;
+ anv_semaphore_impl_cleanup(device, &semaphore->temporary);
+ anv_semaphore_impl_cleanup(device, &semaphore->permanent);
+
vk_free2(&device->alloc, pAllocator, semaphore);
}