summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/v3d/v3dx_draw.c
diff options
context:
space:
mode:
authorJose Maria Casanova Crespo <jmcasanova@igalia.com>2019-11-11 01:46:24 +0100
committerDylan Baker <dylan@pnwbakers.com>2020-02-25 08:53:12 -0800
commite1dc5cc75724317cbc6d2b467b6504e6a561dab7 (patch)
tree6eb4ac8c74bc6029909a22b2fb3aec94c9406b23 /src/gallium/drivers/v3d/v3dx_draw.c
parent312a81ec61f719be46ad1ac6a36fd84916d109de (diff)
downloadmesa-e1dc5cc75724317cbc6d2b467b6504e6a561dab7.tar.gz
v3d: Sync on last CS when non-compute stage uses resource written by CS
When a resource is written by a compute shader and then used by a non-compute stage we sync on last compute job to guarantee that the resource has been completely written when the next stage reads resources. In the other cases how flushes are done guarantee the serialization of the writes and reads. To reproduce the failure the following tests should be executed in batch as last test don't fail when run isolated: KHR-GLES31.core.shader_image_load_store.basic-allFormats-load-fs KHR-GLES31.core.shader_image_load_store.basic-allFormats-loadStoreComputeStage KHR-GLES31.core.shader_image_load_store.basic-allTargets-load-cs KHR-GLES31.core.shader_image_load_store.advanced-sync-vertexArray v2: Use fence dep instead of bo_wait (Eric Anholt) v3: Rename struct names (Iago Toral) Document why is not needed on graphics->compute case. (Iago Toral) Follow same code pattern of the other update of in_sync_bcl. v4: Fixed comments style. (Iago Toral) Fixes KHR-GLES31.core.shader_image_load_store.advanced-sync-vertexArray Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> CC: 19.3 20.0 <mesa-stable@lists.freedesktop.org> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2700> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/2700> (cherry picked from commit 01496e3d1ea0370af03e6645dbd2b864c2ace94c)
Diffstat (limited to 'src/gallium/drivers/v3d/v3dx_draw.c')
-rw-r--r--src/gallium/drivers/v3d/v3dx_draw.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c
index 3a5b1171020..91ae5ba4911 100644
--- a/src/gallium/drivers/v3d/v3dx_draw.c
+++ b/src/gallium/drivers/v3d/v3dx_draw.c
@@ -157,7 +157,8 @@ v3d_predraw_check_stage_inputs(struct pipe_context *pctx,
v3d_update_shadow_texture(pctx, &view->base);
v3d_flush_jobs_writing_resource(v3d, view->texture,
- V3D_FLUSH_DEFAULT);
+ V3D_FLUSH_DEFAULT,
+ s == PIPE_SHADER_COMPUTE);
}
/* Flush writes to UBOs. */
@@ -165,7 +166,8 @@ v3d_predraw_check_stage_inputs(struct pipe_context *pctx,
struct pipe_constant_buffer *cb = &v3d->constbuf[s].cb[i];
if (cb->buffer) {
v3d_flush_jobs_writing_resource(v3d, cb->buffer,
- V3D_FLUSH_DEFAULT);
+ V3D_FLUSH_DEFAULT,
+ s == PIPE_SHADER_COMPUTE);
}
}
@@ -174,7 +176,8 @@ v3d_predraw_check_stage_inputs(struct pipe_context *pctx,
struct pipe_shader_buffer *sb = &v3d->ssbo[s].sb[i];
if (sb->buffer) {
v3d_flush_jobs_reading_resource(v3d, sb->buffer,
- V3D_FLUSH_NOT_CURRENT_JOB);
+ V3D_FLUSH_NOT_CURRENT_JOB,
+ s == PIPE_SHADER_COMPUTE);
}
}
@@ -183,7 +186,8 @@ v3d_predraw_check_stage_inputs(struct pipe_context *pctx,
struct v3d_image_view *view = &v3d->shaderimg[s].si[i];
v3d_flush_jobs_reading_resource(v3d, view->base.resource,
- V3D_FLUSH_NOT_CURRENT_JOB);
+ V3D_FLUSH_NOT_CURRENT_JOB,
+ s == PIPE_SHADER_COMPUTE);
}
/* Flush writes to our vertex buffers (i.e. from transform feedback) */
@@ -192,7 +196,8 @@ v3d_predraw_check_stage_inputs(struct pipe_context *pctx,
struct pipe_vertex_buffer *vb = &v3d->vertexbuf.vb[i];
v3d_flush_jobs_writing_resource(v3d, vb->buffer.resource,
- V3D_FLUSH_DEFAULT);
+ V3D_FLUSH_DEFAULT,
+ false);
}
}
}
@@ -213,7 +218,8 @@ v3d_predraw_check_outputs(struct pipe_context *pctx)
const struct pipe_stream_output_target *target =
so->targets[i];
v3d_flush_jobs_reading_resource(v3d, target->buffer,
- V3D_FLUSH_DEFAULT);
+ V3D_FLUSH_DEFAULT,
+ false);
}
}
}
@@ -667,7 +673,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
if (info->indirect) {
v3d_flush_jobs_writing_resource(v3d, info->indirect->buffer,
- V3D_FLUSH_DEFAULT);
+ V3D_FLUSH_DEFAULT, false);
}
v3d_predraw_check_outputs(pctx);
@@ -699,6 +705,14 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
job->submit.in_sync_bcl = v3d->out_sync;
}
+ /* We also need to ensure that compute is complete when render depends
+ * on resources written by it.
+ */
+ if (v3d->sync_on_last_compute_job) {
+ job->submit.in_sync_bcl = v3d->out_sync;
+ v3d->sync_on_last_compute_job = false;
+ }
+
/* Mark SSBOs and images as being written. We don't actually know
* which ones are read vs written, so just assume the worst.
*/
@@ -1114,13 +1128,15 @@ v3d_launch_grid(struct pipe_context *pctx, const struct pipe_grid_info *info)
foreach_bit(i, v3d->ssbo[PIPE_SHADER_COMPUTE].enabled_mask) {
struct v3d_resource *rsc = v3d_resource(
v3d->ssbo[PIPE_SHADER_COMPUTE].sb[i].buffer);
- rsc->writes++; /* XXX */
+ rsc->writes++;
+ rsc->compute_written = true;
}
foreach_bit(i, v3d->shaderimg[PIPE_SHADER_COMPUTE].enabled_mask) {
struct v3d_resource *rsc = v3d_resource(
v3d->shaderimg[PIPE_SHADER_COMPUTE].si[i].base.resource);
rsc->writes++;
+ rsc->compute_written = true;
}
v3d_bo_unreference(&uniforms.bo);