[Mesa-dev] [PATCH 8/9] i965: Check after malloc success in intel_miptree_alloc_hiz()
Kenneth Graunke
kenneth at whitecape.org
Thu Jul 3 14:21:11 PDT 2014
On Thursday, July 03, 2014 11:13:18 AM Juha-Pekka Heikkila wrote:
> Signed-off-by: Juha-Pekka Heikkila <juhapekka.heikkila at gmail.com>
> ---
> src/mesa/drivers/dri/i965/intel_mipmap_tree.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> index 2ab0faa..30030d1 100644
> --- a/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> +++ b/src/mesa/drivers/dri/i965/intel_mipmap_tree.c
> @@ -1399,6 +1399,10 @@ intel_miptree_alloc_hiz(struct brw_context *brw,
>
> for (int layer = 0; layer < mt->level[level].depth; ++layer) {
> struct intel_resolve_map *m = malloc(sizeof(struct
intel_resolve_map));
> + if (!m) {
> + _mesa_error_no_memory(__func__);
> + return false;
> + }
> exec_node_init(&m->link);
> m->level = level;
> m->layer = layer;
>
NAK. This might shut up the tool, but it's almost certainly not correct.
You're leaving HiZ enabled for a level, but in a broken state.
At the very least, I would expect to see mt->level[level].has_hiz = false. I
don't know if that's sufficient.
On Gen7+, HiZ is just an optional optimization, so you should be able to just
turn it off, and have everything continue working, without needing to report
an GL_OUT_OF_MEMORY error.
In particular, you should be able to replace the malloc call here with "m =
NULL", simulating a 100% malloc failure rate, and run Piglit. If you've
solved this problem correctly, everything will continue working - there will
be no crashes, no extra GL errors, and all the tests should continue passing.
On Sandybridge we're probably just screwed, since failing to alloc HiZ (at
least for level 0) means we need to disable separate stencil as well. I
highly recommend ignoring that problem for now.
--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20140703/507e03e7/attachment.sig>
More information about the mesa-dev
mailing list