<div dir="ltr">Hi, <br><div class="gmail_extra"><br><div class="gmail_quote">2017-01-06 1:04 GMT+08:00 Marc-André Lureau <span dir="ltr"><<a href="mailto:mlureau@redhat.com" target="_blank">mlureau@redhat.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-"><br>
> Signed-off-by: Li Qiang <<a href="mailto:liq3ea@gmail.com">liq3ea@gmail.com</a>><br>
> ---<br>
> src/vrend_renderer.c | 4 ++--<br>
> 1 file changed, 2 insertions(+), 2 deletions(-)<br>
><br>
> diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c<br>
> index 00b61eb..cd8055d 100644<br>
> --- a/src/vrend_renderer.c<br>
> +++ b/src/vrend_renderer.c<br>
> @@ -2354,10 +2354,10 @@ void vrend_clear(struct vrend_context *ctx,<br>
> mask = buffers >> 2;<br>
> while (mask) {<br>
> i = u_bit_scan(&mask);<br>
> - if (util_format_is_pure_uint(ctx-<wbr>>sub->surf[i]->format))<br>
> + if (i < 8 && ctx->sub->surf[i] &&<br>
<br>
</span>I would rather introduce a define, VREND_NDRAWBUFFERS ?<br>
<span class="gmail-"><br></span></blockquote><div><br></div><div>True, I would like to use a define, but as the definition of 'surf' is hard coded, so do I.</div><div><br></div><div><div>struct vrend_sub_context {</div><div> struct list_head head;</div><div><br></div><div> ...</div><div> uint32_t fb_id;</div><div> int nr_cbufs, old_nr_cbufs;</div><div> struct vrend_surface *zsurf;</div><div> struct vrend_surface *surf[8];</div></div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> util_format_is_pure_uint(ctx-><wbr>sub->surf[i] && ctx->sub->surf[i]->format))<br>
<br>
</span>That looks wrong, why do you check for ctx->sub->surf[i] twice here?<br>
<span class="gmail-"><br></span></blockquote><div><br></div><div><br></div><div>Here we deref ctx->sub->surf[i]->format, so we should be sure the 'i' is in bound and the surf[i] is not NULL.</div><div>So if i >=8 or surf[i] is NULL in, it will fall in the 'else if', but here we still do this sanity check because we</div><div>don't know the reason of first 'if' fails, by the sanity check or by the call of util_format_is_pure_uint. I have thought </div><div>several solution but it seems every methods will have repeat code. <br></div><div><br></div><div>Any idea?</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">
> glClearBufferuiv(GL_COLOR,<br>
> i, (GLuint *)color);<br>
> - else if (util_format_is_pure_sint(ctx-<wbr>>sub->surf[i]->format))<br>
> + else if (i < 8 && ctx->sub->surf[i] &&<br>
> util_format_is_pure_sint(ctx-><wbr>sub->surf[i] && ctx->sub->surf[i]->format))<br>
> glClearBufferiv(GL_COLOR,<br>
> i, (GLint *)color);<br>
> else<br>
<br>
</span>otherwise, looks ok<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
> --<br>
> 2.7.4<br>
><br>
><br>
</font></span></blockquote></div><br></div></div>