diff options
author | Wladimir J. van der Laan <[email protected]> | 2017-08-23 12:43:14 +0000 |
---|---|---|
committer | Wladimir J. van der Laan <[email protected]> | 2018-03-31 06:17:59 +0000 |
commit | 6be017fdc4c4edd6c1815254f51e8dc2f02d79ac (patch) | |
tree | d97cb2b3eaff2c668eb98ee260d4ce485d17a57e /src/gallium | |
parent | fb413727618608e65013b13f3601ceefe6d36f9b (diff) |
freedreno: a2xx: Prevent crash in emit_texture if view is not set
Textures will sometimes be updated if texture view state was
un-set, without this change that causes an assertion crash or
segfault.
Signed-off-by: Wladimir J. van der Laan <[email protected]>
Reviewed-by: Ilia Mirkin <[email protected]>
Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/freedreno/a2xx/fd2_emit.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c index 5a1db1335e3..a787b71e379 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c @@ -125,8 +125,9 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context *ctx, { unsigned const_idx = fd2_get_const_idx(ctx, tex, samp_id); static const struct fd2_sampler_stateobj dummy_sampler = {}; + static const struct fd2_pipe_sampler_view dummy_view = {}; const struct fd2_sampler_stateobj *sampler; - struct fd2_pipe_sampler_view *view; + const struct fd2_pipe_sampler_view *view; if (emitted & (1 << const_idx)) return 0; @@ -134,13 +135,19 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context *ctx, sampler = tex->samplers[samp_id] ? fd2_sampler_stateobj(tex->samplers[samp_id]) : &dummy_sampler; - view = fd2_pipe_sampler_view(tex->textures[samp_id]); + view = tex->textures[samp_id] ? + fd2_pipe_sampler_view(tex->textures[samp_id]) : + &dummy_view; OUT_PKT3(ring, CP_SET_CONSTANT, 7); OUT_RING(ring, 0x00010000 + (0x6 * const_idx)); OUT_RING(ring, sampler->tex0 | view->tex0); - OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, view->fmt, 0); + if (view->base.texture) + OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, view->fmt, 0); + else + OUT_RING(ring, 0); + OUT_RING(ring, view->tex2); OUT_RING(ring, sampler->tex3 | view->tex3); OUT_RING(ring, sampler->tex4); |