mesa: Mark render-to-texture as unsafe if there's no pipe_resource
Let's be slightly more defensive here. If a texture image doesn't have an associated pipe_resource allocated, then render_texture() will pass that along to _mesa_update_renderbuffer_surface(), which will crash on a NULL pointer dereference. So, if there isn't a pipe_resource, then we should just skip this altogteher. Today, this isn't an issue, because each gl_texture_image always allocates a pipe_resource up front. On a branch of mine, I prototyped some improvements to the compressed texture fallback handling, where it would defer resource allocation, examine the source image's block data, and dynamically select a format based on that, then allocate it later. With that prototype in place, we saw crashes the Android "My Talking Tom" series of games, which appear to be attaching ASTC textures to a framebuffer color attachment. That FBO would be incomplete anyway, as ASTC textures aren't renderable, but we got into a situation where the render-to-texture code was crashing due to the lack of pt before it could properly signal that it was incomplete and bailing. Technically, we don't need this now, but I figure that being defensive won't hurt and this would probably save whoever encounters such an issue in the future a bunch of frustrating debugging. Reviewed-by: Marek Olšák <marek.olsak@amd.com> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17508>
This commit is contained in:
parent
4ba129cd86
commit
03df494ea4
|
@ -512,6 +512,7 @@ driver_RenderTexture_is_safe(const struct gl_renderbuffer_attachment *att)
|
|||
att->Texture->Image[att->CubeMapFace][att->TextureLevel];
|
||||
|
||||
if (!texImage ||
|
||||
!texImage->pt ||
|
||||
texImage->Width == 0 || texImage->Height == 0 || texImage->Depth == 0)
|
||||
return false;
|
||||
|
||||
|
|
Loading…
Reference in New Issue