diff options
author | Eric Anholt <[email protected]> | 2018-12-05 17:10:15 -0800 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-12-07 16:48:23 -0800 |
commit | 503b55c6224f32304852b54d953d9e7d5d144708 (patch) | |
tree | 7f3523690778351bc3fd7033416f19c803cd25fc | |
parent | 504d06e4c1c5664c1e208179a43adbbd27fd4522 (diff) |
v3d: Don't forget to flush writes to UBOs.
If someone did TF into a UBO, we might have left the TF job un-flushed at
the point of reading.
-rw-r--r-- | src/gallium/drivers/v3d/v3d_context.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/v3d/v3dx_draw.c | 18 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index d62dd229ef2..4db422b5755 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -459,6 +459,9 @@ struct v3d_blend_state { fprintf(stderr, __VA_ARGS__); \ } while (0) +#define foreach_bit(b, mask) \ + for (uint32_t _m = (mask), b; _m && ({(b) = u_bit_scan(&_m); 1;});) + static inline struct v3d_context * v3d_context(struct pipe_context *pcontext) { diff --git a/src/gallium/drivers/v3d/v3dx_draw.c b/src/gallium/drivers/v3d/v3dx_draw.c index 519aa9157d5..ca0a1ab39c2 100644 --- a/src/gallium/drivers/v3d/v3dx_draw.c +++ b/src/gallium/drivers/v3d/v3dx_draw.c @@ -119,18 +119,26 @@ v3d_start_draw(struct v3d_context *v3d) } static void -v3d_predraw_check_textures(struct pipe_context *pctx, - struct v3d_texture_stateobj *stage_tex) +v3d_predraw_check_stage_inputs(struct pipe_context *pctx, + enum pipe_shader_type s) { struct v3d_context *v3d = v3d_context(pctx); - for (int i = 0; i < stage_tex->num_textures; i++) { - struct pipe_sampler_view *view = stage_tex->textures[i]; + /* Flush writes to textures we're sampling. */ + for (int i = 0; i < v3d->tex[s].num_textures; i++) { + struct pipe_sampler_view *view = v3d->tex[s].textures[i]; if (!view) continue; v3d_flush_jobs_writing_resource(v3d, view->texture); } + + /* Flush writes to UBOs. */ + foreach_bit(i, v3d->constbuf[s].enabled_mask) { + struct pipe_constant_buffer *cb = &v3d->constbuf[s].cb[i]; + if (cb->buffer) + v3d_flush_jobs_writing_resource(v3d, cb->buffer); + } } static void @@ -436,7 +444,7 @@ v3d_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info) * that we read from. */ for (int s = 0; s < PIPE_SHADER_TYPES; s++) - v3d_predraw_check_textures(pctx, &v3d->tex[s]); + v3d_predraw_check_stage_inputs(pctx, s); struct v3d_job *job = v3d_get_job_for_fbo(v3d); |