This gives us access to the fence created for the render job. v2: Drop flag (Eric) Signed-off-by: Stefan Schake <stschake@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>tags/18.2-branchpoint
@@ -124,6 +124,9 @@ vc4_context_destroy(struct pipe_context *pctx) | |||
vc4_program_fini(pctx); | |||
if (vc4->screen->has_syncobj) | |||
drmSyncobjDestroy(vc4->fd, vc4->job_syncobj); | |||
ralloc_free(vc4); | |||
} | |||
@@ -132,6 +135,7 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) | |||
{ | |||
struct vc4_screen *screen = vc4_screen(pscreen); | |||
struct vc4_context *vc4; | |||
int err; | |||
/* Prevent dumping of the shaders built during context setup. */ | |||
uint32_t saved_shaderdb_flag = vc4_debug & VC4_DEBUG_SHADERDB; | |||
@@ -157,10 +161,12 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) | |||
vc4_query_init(pctx); | |||
vc4_resource_context_init(pctx); | |||
vc4_job_init(vc4); | |||
vc4->fd = screen->fd; | |||
err = vc4_job_init(vc4); | |||
if (err) | |||
goto fail; | |||
slab_create_child(&vc4->transfer_pool, &screen->transfer_pool); | |||
vc4->uploader = u_upload_create_default(&vc4->base); |
@@ -408,6 +408,9 @@ struct vc4_context { | |||
struct vc4_hwperfmon *perfmon; | |||
/** @} */ | |||
/** Handle of syncobj containing the last submitted job fence. */ | |||
uint32_t job_syncobj; | |||
}; | |||
struct vc4_rasterizer_state { | |||
@@ -502,7 +505,7 @@ void vc4_write_uniforms(struct vc4_context *vc4, | |||
struct vc4_texture_stateobj *texstate); | |||
void vc4_flush(struct pipe_context *pctx); | |||
void vc4_job_init(struct vc4_context *vc4); | |||
int vc4_job_init(struct vc4_context *vc4); | |||
struct vc4_job *vc4_get_job(struct vc4_context *vc4, | |||
struct pipe_surface *cbuf, | |||
struct pipe_surface *zsbuf); |
@@ -477,6 +477,9 @@ vc4_job_submit(struct vc4_context *vc4, struct vc4_job *job) | |||
} | |||
submit.flags |= job->flags; | |||
if (vc4->screen->has_syncobj) | |||
submit.out_sync = vc4->job_syncobj; | |||
if (!(vc4_debug & VC4_DEBUG_NORAST)) { | |||
int ret; | |||
@@ -530,7 +533,7 @@ vc4_job_hash(const void *key) | |||
return _mesa_hash_data(key, sizeof(struct vc4_job_key)); | |||
} | |||
void | |||
int | |||
vc4_job_init(struct vc4_context *vc4) | |||
{ | |||
vc4->jobs = _mesa_hash_table_create(vc4, | |||
@@ -539,5 +542,24 @@ vc4_job_init(struct vc4_context *vc4) | |||
vc4->write_jobs = _mesa_hash_table_create(vc4, | |||
_mesa_hash_pointer, | |||
_mesa_key_pointer_equal); | |||
if (vc4->screen->has_syncobj) { | |||
/* Create the syncobj as signaled since with no job executed | |||
* there is nothing to wait on. | |||
*/ | |||
int ret = drmSyncobjCreate(vc4->fd, | |||
DRM_SYNCOBJ_CREATE_SIGNALED, | |||
&vc4->job_syncobj); | |||
if (ret) { | |||
/* If the screen indicated syncobj support, we should | |||
* be able to create a signaled syncobj. | |||
* At this point it is too late to pretend the screen | |||
* has no syncobj support. | |||
*/ | |||
return ret; | |||
} | |||
} | |||
return 0; | |||
} | |||