diff options
author | Marek Olšák <[email protected]> | 2015-09-10 18:40:51 +0200 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2015-10-07 14:40:36 +0100 |
commit | b2d3012e351b0f2524ff4990ba424e8ebb0bb727 (patch) | |
tree | 79c6ef7d24d2c354a36de9fefa6bb7f8c6760405 /src/gallium/drivers | |
parent | 154573e4279ae7720c65d657144da353a6869b0c (diff) |
radeonsi: skip drawing if updating the scratch buffer fails
Cc: 11.0 <[email protected]>
Acked-by: Christian König <[email protected]>
Reviewed-by: Michel Dänzer <[email protected]>
(cherry picked from commit d556346b3590e8d5601c0831577f08e7b1ccecec)
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 9a854e25998..c1ee497a3bc 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -1119,14 +1119,16 @@ static void si_update_gs_rings(struct si_context *sctx) } /** - * @returns 1 if \p sel has been updated to use a new scratch buffer and 0 - * otherwise. + * @returns 1 if \p sel has been updated to use a new scratch buffer + * 0 if not + * < 0 if there was a failure */ -static unsigned si_update_scratch_buffer(struct si_context *sctx, +static int si_update_scratch_buffer(struct si_context *sctx, struct si_shader_selector *sel) { struct si_shader *shader; uint64_t scratch_va = sctx->scratch_buffer->gpu_address; + int r; if (!sel) return 0; @@ -1147,7 +1149,9 @@ static unsigned si_update_scratch_buffer(struct si_context *sctx, si_shader_apply_scratch_relocs(sctx, shader, scratch_va); /* Replace the shader bo with a new bo that has the relocs applied. */ - si_shader_binary_upload(sctx->screen, shader); + r = si_shader_binary_upload(sctx->screen, shader); + if (r) + return r; /* Update the shader state to use the new shader bo. */ si_shader_init_pm4_state(shader); @@ -1186,7 +1190,7 @@ static unsigned si_get_max_scratch_bytes_per_wave(struct si_context *sctx) return bytes; } -static void si_update_spi_tmpring_size(struct si_context *sctx) +static bool si_update_spi_tmpring_size(struct si_context *sctx) { unsigned current_scratch_buffer_size = si_get_current_scratch_buffer_size(sctx); @@ -1194,6 +1198,7 @@ static void si_update_spi_tmpring_size(struct si_context *sctx) si_get_max_scratch_bytes_per_wave(sctx); unsigned scratch_needed_size = scratch_bytes_per_wave * sctx->scratch_waves; + int r; if (scratch_needed_size > 0) { @@ -1206,6 +1211,8 @@ static void si_update_spi_tmpring_size(struct si_context *sctx) sctx->scratch_buffer = si_resource_create_custom(&sctx->screen->b.b, PIPE_USAGE_DEFAULT, scratch_needed_size); + if (!sctx->scratch_buffer) + return false; } /* Update the shaders, so they are using the latest scratch. The @@ -1213,31 +1220,57 @@ static void si_update_spi_tmpring_size(struct si_context *sctx) * last used, so we still need to try to update them, even if * they require scratch buffers smaller than the current size. */ - if (si_update_scratch_buffer(sctx, sctx->ps_shader)) + r = si_update_scratch_buffer(sctx, sctx->ps_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, ps, sctx->ps_shader->current->pm4); - if (si_update_scratch_buffer(sctx, sctx->gs_shader)) + + r = si_update_scratch_buffer(sctx, sctx->gs_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, gs, sctx->gs_shader->current->pm4); - if (si_update_scratch_buffer(sctx, sctx->tcs_shader)) + + r = si_update_scratch_buffer(sctx, sctx->tcs_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, hs, sctx->tcs_shader->current->pm4); /* VS can be bound as LS, ES, or VS. */ if (sctx->tes_shader) { - if (si_update_scratch_buffer(sctx, sctx->vs_shader)) + r = si_update_scratch_buffer(sctx, sctx->vs_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, ls, sctx->vs_shader->current->pm4); } else if (sctx->gs_shader) { - if (si_update_scratch_buffer(sctx, sctx->vs_shader)) + r = si_update_scratch_buffer(sctx, sctx->vs_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, es, sctx->vs_shader->current->pm4); } else { - if (si_update_scratch_buffer(sctx, sctx->vs_shader)) + r = si_update_scratch_buffer(sctx, sctx->vs_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, vs, sctx->vs_shader->current->pm4); } /* TES can be bound as ES or VS. */ if (sctx->gs_shader) { - if (si_update_scratch_buffer(sctx, sctx->tes_shader)) + r = si_update_scratch_buffer(sctx, sctx->tes_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, es, sctx->tes_shader->current->pm4); } else { - if (si_update_scratch_buffer(sctx, sctx->tes_shader)) + r = si_update_scratch_buffer(sctx, sctx->tes_shader); + if (r < 0) + return false; + if (r == 1) si_pm4_bind_state(sctx, vs, sctx->tes_shader->current->pm4); } } @@ -1248,6 +1281,7 @@ static void si_update_spi_tmpring_size(struct si_context *sctx) sctx->spi_tmpring_size = S_0286E8_WAVES(sctx->scratch_waves) | S_0286E8_WAVESIZE(scratch_bytes_per_wave >> 10); + return true; } static void si_init_tess_factor_ring(struct si_context *sctx) @@ -1480,7 +1514,8 @@ bool si_update_shaders(struct si_context *sctx) if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) || si_pm4_state_changed(sctx, gs)) { - si_update_spi_tmpring_size(sctx); + if (!si_update_spi_tmpring_size(sctx)) + return false; } if (sctx->ps_db_shader_control != sctx->ps_shader->current->db_shader_control) { |