diff --git a/src/gallium/drivers/lima/lima_program.c b/src/gallium/drivers/lima/lima_program.c index a07c7251bef..891c3d47f70 100644 --- a/src/gallium/drivers/lima/lima_program.c +++ b/src/gallium/drivers/lima/lima_program.c @@ -591,15 +591,19 @@ lima_update_fs_state(struct lima_context *ctx) memcpy(key->nir_sha1, ctx->uncomp_fs->nir_sha1, sizeof(ctx->uncomp_fs->nir_sha1)); + uint8_t identity[4] = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, + PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W }; for (int i = 0; i < lima_tex->num_textures; i++) { struct lima_sampler_view *sampler = lima_sampler_view(lima_tex->textures[i]); + if (!sampler) { + memcpy(key->tex[i].swizzle, identity, 4); + continue; + } for (int j = 0; j < 4; j++) key->tex[i].swizzle[j] = sampler->swizzle[j]; } /* Fill rest with identity swizzle */ - uint8_t identity[4] = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, - PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W }; for (int i = lima_tex->num_textures; i < ARRAY_SIZE(key->tex); i++) memcpy(key->tex[i].swizzle, identity, 4); diff --git a/src/gallium/drivers/lima/lima_texture.c b/src/gallium/drivers/lima/lima_texture.c index 1ec03dea9ff..2dfb293b73b 100644 --- a/src/gallium/drivers/lima/lima_texture.c +++ b/src/gallium/drivers/lima/lima_texture.c @@ -161,6 +161,9 @@ lima_update_tex_desc(struct lima_context *ctx, struct lima_sampler_state *sample memset(desc, 0, desc_size); + if (!texture) + return; + switch (texture->base.target) { case PIPE_TEXTURE_1D: desc->sampler_dim = LIMA_SAMPLER_DIM_1D; @@ -260,6 +263,10 @@ lima_calc_tex_desc_size(struct lima_sampler_view *texture) { unsigned size = offsetof(lima_tex_desc, va); unsigned va_bit_size; + + if (!texture) + return lima_min_tex_desc_size; + unsigned first_level = texture->base.u.tex.first_level; unsigned last_level = texture->base.u.tex.last_level; @@ -288,6 +295,8 @@ lima_update_textures(struct lima_context *ctx) /* we always need to add texture bo to job */ for (int i = 0; i < lima_tex->num_samplers; i++) { struct lima_sampler_view *texture = lima_sampler_view(lima_tex->textures[i]); + if (!texture) + continue; struct lima_resource *rsc = lima_resource(texture->base.texture); lima_flush_previous_job_writing_resource(ctx, texture->base.texture); lima_job_add_bo(job, LIMA_PIPE_PP, rsc->bo, LIMA_SUBMIT_BO_READ);