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 <alyssa.rosenzweig@collabora.com>
This commit is contained in:
parent
79b13b4376
commit
227c395c00
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in New Issue