(adjusted by Ken to make the signalling sync object immediately on batch reset, rather than batch finish time. this will work better with deferred flushes...)tags/19.1-branchpoint
@@ -40,6 +40,7 @@ | |||
#include "iris_batch.h" | |||
#include "iris_bufmgr.h" | |||
#include "iris_context.h" | |||
#include "iris_fence.h" | |||
#include "drm-uapi/i915_drm.h" | |||
@@ -183,6 +184,7 @@ iris_init_batch(struct iris_batch *batch, | |||
assert(batch->hw_ctx_id); | |||
util_dynarray_init(&batch->exec_fences, ralloc_context(NULL)); | |||
util_dynarray_init(&batch->syncpts, ralloc_context(NULL)); | |||
batch->exec_count = 0; | |||
batch->exec_array_size = 100; | |||
@@ -345,6 +347,8 @@ create_batch(struct iris_batch *batch) | |||
static void | |||
iris_batch_reset(struct iris_batch *batch) | |||
{ | |||
struct iris_screen *screen = batch->screen; | |||
iris_bo_unreference(batch->bo); | |||
batch->primary_batch_size = 0; | |||
batch->contains_draw = false; | |||
@@ -352,6 +356,10 @@ iris_batch_reset(struct iris_batch *batch) | |||
create_batch(batch); | |||
assert(batch->bo->index == 0); | |||
struct iris_syncpt *syncpt = iris_create_syncpt(screen); | |||
iris_batch_add_syncpt(batch, syncpt, I915_EXEC_FENCE_SIGNAL); | |||
iris_syncpt_reference(screen, &syncpt, NULL); | |||
if (batch->state_sizes) | |||
_mesa_hash_table_clear(batch->state_sizes, NULL); | |||
@@ -372,6 +380,10 @@ iris_batch_free(struct iris_batch *batch) | |||
ralloc_free(batch->exec_fences.mem_ctx); | |||
util_dynarray_foreach(&batch->syncpts, struct iris_syncpt *, s) | |||
iris_syncpt_reference(screen, s, NULL); | |||
ralloc_free(batch->syncpts.mem_ctx); | |||
iris_bo_unreference(batch->bo); | |||
batch->bo = NULL; | |||
batch->map = NULL; | |||
@@ -517,6 +529,8 @@ submit_batch(struct iris_batch *batch) | |||
void | |||
_iris_batch_flush(struct iris_batch *batch, const char *file, int line) | |||
{ | |||
struct iris_screen *screen = batch->screen; | |||
if (iris_batch_bytes_used(batch) == 0) | |||
return; | |||
@@ -566,6 +580,10 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line) | |||
batch->exec_count = 0; | |||
batch->aperture_space = 0; | |||
util_dynarray_foreach(&batch->syncpts, struct iris_syncpt *, s) | |||
iris_syncpt_reference(screen, s, NULL); | |||
util_dynarray_clear(&batch->syncpts); | |||
util_dynarray_clear(&batch->exec_fences); | |||
/* Start a new batch buffer. */ |
@@ -76,6 +76,15 @@ struct iris_batch { | |||
int exec_count; | |||
int exec_array_size; | |||
/** | |||
* A list of iris_syncpts associated with this batch. | |||
* | |||
* The first list entry will always be a signalling sync-point, indicating | |||
* that this batch has completed. The others are likely to be sync-points | |||
* to wait on before executing the batch. | |||
*/ | |||
struct util_dynarray syncpts; | |||
/** A list of drm_i915_exec_fences to have execbuf signal or wait on */ | |||
struct util_dynarray exec_fences; | |||
@@ -0,0 +1,107 @@ | |||
/* | |||
* Copyright © 2018 Intel Corporation | |||
* | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the "Software"), | |||
* to deal in the Software without restriction, including without limitation | |||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
* and/or sell copies of the Software, and to permit persons to whom the | |||
* Software is furnished to do so, subject to the following conditions: | |||
* | |||
* The above copyright notice and this permission notice shall be included | |||
* in all copies or substantial portions of the Software. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | |||
* DEALINGS IN THE SOFTWARE. | |||
*/ | |||
/** | |||
* @file iris_fence.c | |||
* | |||
* Fences for driver and IPC serialisation, scheduling and synchronisation. | |||
*/ | |||
#include "util/u_inlines.h" | |||
#include "iris_batch.h" | |||
#include "iris_bufmgr.h" | |||
#include "iris_fence.h" | |||
#include "iris_screen.h" | |||
static uint32_t | |||
gem_syncobj_create(int fd, uint32_t flags) | |||
{ | |||
struct drm_syncobj_create args = { | |||
.flags = flags, | |||
}; | |||
drm_ioctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args); | |||
return args.handle; | |||
} | |||
static void | |||
gem_syncobj_destroy(int fd, uint32_t handle) | |||
{ | |||
struct drm_syncobj_destroy args = { | |||
.handle = handle, | |||
}; | |||
drm_ioctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args); | |||
} | |||
/** | |||
* Make a new sync-point. | |||
*/ | |||
struct iris_syncpt * | |||
iris_create_syncpt(struct iris_screen *screen) | |||
{ | |||
struct iris_syncpt *syncpt = malloc(sizeof(*syncpt)); | |||
if (!syncpt) | |||
return NULL; | |||
syncpt->handle = gem_syncobj_create(screen->fd, 0); | |||
assert(syncpt->handle); | |||
pipe_reference_init(&syncpt->ref, 1); | |||
return syncpt; | |||
} | |||
void | |||
iris_syncpt_destroy(struct iris_screen *screen, struct iris_syncpt *syncpt) | |||
{ | |||
gem_syncobj_destroy(screen->fd, syncpt->handle); | |||
free(syncpt); | |||
} | |||
/** | |||
* Add a sync-point to the batch, with the given flags. | |||
* | |||
* \p flags One of I915_EXEC_FENCE_WAIT or I915_EXEC_FENCE_SIGNAL. | |||
*/ | |||
void | |||
iris_batch_add_syncpt(struct iris_batch *batch, | |||
struct iris_syncpt *syncpt, | |||
unsigned flags) | |||
{ | |||
struct drm_i915_gem_exec_fence *fence = | |||
util_dynarray_grow(&batch->exec_fences, sizeof(*fence)); | |||
*fence = (struct drm_i915_gem_exec_fence) { | |||
.handle = syncpt->handle, | |||
.flags = flags, | |||
}; | |||
struct iris_syncpt **store = | |||
util_dynarray_grow(&batch->syncpts, sizeof(*store)); | |||
*store = NULL; | |||
iris_syncpt_reference(batch->screen, store, syncpt); | |||
} |
@@ -0,0 +1,53 @@ | |||
/* | |||
* Copyright © 2018 Intel Corporation | |||
* | |||
* Permission is hereby granted, free of charge, to any person obtaining a | |||
* copy of this software and associated documentation files (the "Software"), | |||
* to deal in the Software without restriction, including without limitation | |||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, | |||
* and/or sell copies of the Software, and to permit persons to whom the | |||
* Software is furnished to do so, subject to the following conditions: | |||
* | |||
* The above copyright notice and this permission notice (including the next | |||
* paragraph) shall be included in all copies or substantial portions of the | |||
* Software. | |||
* | |||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | |||
* IN THE SOFTWARE. | |||
*/ | |||
#ifndef IRIS_FENCE_H | |||
#define IRIS_FENCE_H | |||
#include "util/u_inlines.h" | |||
struct pipe_screen; | |||
struct iris_syncpt { | |||
struct pipe_reference ref; | |||
uint32_t handle; | |||
}; | |||
struct iris_syncpt *iris_create_syncpt(struct iris_screen *screen); | |||
void iris_syncpt_destroy(struct iris_screen *, struct iris_syncpt *); | |||
void iris_batch_add_syncpt(struct iris_batch *batch, | |||
struct iris_syncpt *syncpt, | |||
unsigned flags); | |||
static inline void | |||
iris_syncpt_reference(struct iris_screen *screen, | |||
struct iris_syncpt **dst, | |||
struct iris_syncpt *src) | |||
{ | |||
if (pipe_reference(&(*dst)->ref, &src->ref)) | |||
iris_syncpt_destroy(screen, *dst); | |||
*dst = src; | |||
} | |||
#endif |
@@ -44,6 +44,7 @@ | |||
#include "drm-uapi/i915_drm.h" | |||
#include "iris_context.h" | |||
#include "iris_defines.h" | |||
#include "iris_fence.h" | |||
#include "iris_pipe.h" | |||
#include "iris_resource.h" | |||
#include "iris_screen.h" |
@@ -31,6 +31,8 @@ files_libiris = files( | |||
'iris_context.c', | |||
'iris_context.h', | |||
'iris_draw.c', | |||
'iris_fence.c', | |||
'iris_fence.h', | |||
'iris_formats.c', | |||
'iris_pipe.h', | |||
'iris_pipe_control.c', |