diff options
author | Alyssa Rosenzweig <[email protected]> | 2019-07-18 10:59:59 -0700 |
---|---|---|
committer | Alyssa Rosenzweig <[email protected]> | 2019-07-18 15:25:40 -0700 |
commit | 227c395c00b69fc105546d479d751d92e923b4fc (patch) | |
tree | 4d37bdaffdaa4a6938662a9689744157dfe67204 | |
parent | 79b13b437685b8dbe2e9938714eb4733b8b79a17 (diff) |
panfrost: Check for NULL surface in places
Fixes a bunch of NULL dereferences, although it does cause GPU faults of
course.
This is caused by color buffers masked out in MRT, which we'll
eventually have to solve the right way... one thing at a time.
Signed-off-by: Alyssa Rosenzweig <[email protected]>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_blend_cso.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_fragment.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_mfbd.c | 4 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_resource.c | 5 |
5 files changed, 14 insertions, 5 deletions
diff --git a/src/gallium/drivers/panfrost/pan_blend_cso.c b/src/gallium/drivers/panfrost/pan_blend_cso.c index 5055d2d854e..a96e7b02cd4 100644 --- a/src/gallium/drivers/panfrost/pan_blend_cso.c +++ b/src/gallium/drivers/panfrost/pan_blend_cso.c @@ -212,7 +212,7 @@ panfrost_get_blend_for_context(struct panfrost_context *ctx, unsigned rti) struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer; enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM; - if (fb->nr_cbufs > rti) + if ((fb->nr_cbufs > rti) && fb->cbufs[rti]) fmt = fb->cbufs[rti]->format; /* Grab the blend state */ diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index d01503e43a9..06943c22b44 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1213,11 +1213,10 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data) struct midgard_blend_rt rts[4]; - /* TODO: MRT */ - - for (unsigned i = 0; i < 1; ++i) { + for (unsigned i = 0; i < ctx->pipe_framebuffer.nr_cbufs; ++i) { bool is_srgb = (ctx->pipe_framebuffer.nr_cbufs > i) && + (ctx->pipe_framebuffer.cbufs[i]) && util_format_is_srgb(ctx->pipe_framebuffer.cbufs[i]->format); rts[i].flags = blend_count; diff --git a/src/gallium/drivers/panfrost/pan_fragment.c b/src/gallium/drivers/panfrost/pan_fragment.c index 7ffb9db0a05..023569ef204 100644 --- a/src/gallium/drivers/panfrost/pan_fragment.c +++ b/src/gallium/drivers/panfrost/pan_fragment.c @@ -35,6 +35,9 @@ panfrost_initialize_surface( struct panfrost_job *batch, struct pipe_surface *surf) { + if (!surf) + return; + unsigned level = surf->u.tex.level; struct panfrost_resource *rsrc = pan_resource(surf->texture); diff --git a/src/gallium/drivers/panfrost/pan_mfbd.c b/src/gallium/drivers/panfrost/pan_mfbd.c index e3595af4cf1..c9f3dc315a0 100644 --- a/src/gallium/drivers/panfrost/pan_mfbd.c +++ b/src/gallium/drivers/panfrost/pan_mfbd.c @@ -403,6 +403,10 @@ panfrost_mfbd_fragment(struct panfrost_context *ctx, bool has_draws) for (int cb = 0; cb < ctx->pipe_framebuffer.nr_cbufs; ++cb) { struct pipe_surface *surf = ctx->pipe_framebuffer.cbufs[cb]; + + if (!surf) + continue; + unsigned bpp = util_format_get_blocksize(surf->format); panfrost_mfbd_set_cbuf(&rts[cb], surf); diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index d3cbfe70c77..3f8d50cad73 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -507,7 +507,10 @@ panfrost_transfer_map(struct pipe_context *pctx, bool is_bound = false; for (unsigned c = 0; c < fb->nr_cbufs; ++c) { - is_bound |= fb->cbufs[c]->texture == resource; + /* If cbufs is NULL, we're definitely not bound here */ + + if (fb->cbufs[c]) + is_bound |= fb->cbufs[c]->texture == resource; } if (is_bound && (usage & PIPE_TRANSFER_READ)) { |