<div dir="auto">This only example of code, that we can use for check is_format_supported call. Its not real world code.<br><br><div data-smartmail="gmail_signature"><br>Best regards,<br> Denis.</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sep 13, 2017 11:15 AM, "Nicolai Hähnle" <<a href="mailto:nhaehnle@gmail.com">nhaehnle@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 13.09.2017 08:26, Denis Pauk wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Little additional note:<br>
<br>
This checks related to possible issue with such kind of supported format check in external code:<br>
<br>
----<br>
for(int i=0; i<PIPE_FORMAT_COUNT + 10; i++) {<br>
pscreen->is_format_supported(p<wbr>screen, i, PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);<br>
}<br>
-----<br>
<br>
When we have segfault with: 73, 78, 79, 80, 81,<br>
<br>
86 (holes in enum pipe_format) and format value<br>
<br>
bigger than PIPE_FORMAT_COUNT.<br>
</blockquote>
<br>
Arguably, that code should call util_format_description() and skip the format is the result is NULL.<br>
<br>
And why on earth is that code looping until PIPE_FORMAT_COUNT + 10 in the first place? That never makes sense.<br>
<br>
Cheers,<br>
Nicolai<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
<br>
<br>
Best regards,<br>
Denis.<br>
<br>
On Sep 13, 2017 7:54 AM, "Денис Паук" <<a href="mailto:pauk.denis@gmail.com" target="_blank">pauk.denis@gmail.com</a> <mailto:<a href="mailto:pauk.denis@gmail.com" target="_blank">pauk.denis@gmail.com</a>>> wrote:<br>
<br>
Do you mean delete check in u_format.c:: util_format_is_supported?<br>
Could you please explain more?<br>
<br>
On Wed, Sep 13, 2017 at 1:32 AM, Marek Olšák <<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a><br>
<mailto:<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>>> wrote:<br>
<br>
On Wed, Sep 13, 2017 at 12:31 AM, Marek Olšák <<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a><br>
<mailto:<a href="mailto:maraeo@gmail.com" target="_blank">maraeo@gmail.com</a>>> wrote:<br>
> I think we shouldn't be getting PIPE_FORMAT_COUNT in<br>
> is_format_supported in the first place, and therefore drivers don't<br>
> have to work around it.<br>
<br>
Or any other invalid formats, for that matter.<br>
<br>
Marek<br>
<br>
><br>
> Marek<br>
><br>
> On Tue, Sep 12, 2017 at 10:38 PM, Denis Pauk<br>
<<a href="mailto:pauk.denis@gmail.com" target="_blank">pauk.denis@gmail.com</a> <mailto:<a href="mailto:pauk.denis@gmail.com" target="_blank">pauk.denis@gmail.com</a>>> wrote:<br>
>> Bugzilla:<br>
<a href="https://bugs.freedesktop.org/show_bug.cgi?id=102552" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/s<wbr>how_bug.cgi?id=102552</a><br>
<<a href="https://bugs.freedesktop.org/show_bug.cgi?id=102552" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/<wbr>show_bug.cgi?id=102552</a>><br>
>><br>
>> v2: Patch cleanup proposed by Nicolai Hähnle.<br>
>> * deleted changes in si_translate_texformat.<br>
>><br>
>> Cc: Nicolai Hähnle <<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a><br>
<mailto:<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>>><br>
>> Cc: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a><br>
<mailto:<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>>><br>
>> ---<br>
>> src/gallium/auxiliary/util/u_f<wbr>ormat.c | 4 ++++<br>
>> src/gallium/drivers/r600/r600_<wbr>state_common.c | 4 ++++<br>
>> src/gallium/drivers/radeonsi/s<wbr>i_state.c | 10 +++++++++-<br>
>> 3 files changed, 17 insertions(+), 1 deletion(-)<br>
>><br>
>> diff --git a/src/gallium/auxiliary/util/u<wbr>_format.c<br>
b/src/gallium/auxiliary/util/u<wbr>_format.c<br>
>> index 3d281905ce..a6d42a428d 100644<br>
>> --- a/src/gallium/auxiliary/util/u<wbr>_format.c<br>
>> +++ b/src/gallium/auxiliary/util/u<wbr>_format.c<br>
>> @@ -238,6 +238,10 @@ util_format_is_subsampled_422(<wbr>enum<br>
pipe_format format)<br>
>> boolean<br>
>> util_format_is_supported(enum pipe_format format, unsigned<br>
bind)<br>
>> {<br>
>> + if (format >= PIPE_FORMAT_COUNT) {<br>
>> + return FALSE;<br>
>> + }<br>
>> +<br>
>> if (util_format_is_s3tc(format) &&<br>
!util_format_s3tc_enabled) {<br>
>> return FALSE;<br>
>> }<br>
>> diff --git a/src/gallium/drivers/r600/r60<wbr>0_state_common.c<br>
b/src/gallium/drivers/r600/r60<wbr>0_state_common.c<br>
>> index c1bce8304b..1515c28091 100644<br>
>> --- a/src/gallium/drivers/r600/r60<wbr>0_state_common.c<br>
>> +++ b/src/gallium/drivers/r600/r60<wbr>0_state_common.c<br>
>> @@ -2284,6 +2284,8 @@ uint32_t<br>
r600_translate_texformat(struc<wbr>t pipe_screen *screen,<br>
>> format = PIPE_FORMAT_A4R4_UNORM;<br>
>><br>
>> desc = util_format_description(format<wbr>);<br>
>> + if (!desc)<br>
>> + goto out_unknown;<br>
>><br>
>> /* Depth and stencil swizzling is handled separately. */<br>
>> if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {<br>
>> @@ -2650,6 +2652,8 @@ uint32_t<br>
r600_translate_colorformat(enu<wbr>m chip_class chip, enum<br>
pipe_format forma<br>
>> const struct util_format_description *desc =<br>
util_format_description(format<wbr>);<br>
>> int channel =<br>
util_format_get_first_non_void<wbr>_channel(format);<br>
>> bool is_float;<br>
>> + if (!desc)<br>
>> + return ~0U;<br>
>><br>
>> #define HAS_SIZE(x,y,z,w) \<br>
>> (desc->channel[0].size == (x) &&<br>
desc->channel[1].size == (y) && \<br>
>> diff --git a/src/gallium/drivers/radeonsi<wbr>/si_state.c<br>
b/src/gallium/drivers/radeonsi<wbr>/si_state.c<br>
>> index ee070107fd..f7ee24bdc6 100644<br>
>> --- a/src/gallium/drivers/radeonsi<wbr>/si_state.c<br>
>> +++ b/src/gallium/drivers/radeonsi<wbr>/si_state.c<br>
>> @@ -1292,6 +1292,8 @@ static void<br>
si_emit_db_render_state(struct si_context *sctx, struct r600_atom *s<br>
>> static uint32_t si_translate_colorformat(enum pipe_format<br>
format)<br>
>> {<br>
>> const struct util_format_description *desc =<br>
util_format_description(format<wbr>);<br>
>> + if (!desc)<br>
>> + return V_028C70_COLOR_INVALID;<br>
>><br>
>> #define HAS_SIZE(x,y,z,w) \<br>
>> (desc->channel[0].size == (x) &&<br>
desc->channel[1].size == (y) && \<br>
>> @@ -1796,7 +1798,11 @@ static unsigned si_tex_dim(struct<br>
si_screen *sscreen, struct r600_texture *rtex,<br>
>><br>
>> static bool si_is_sampler_format_supported<wbr>(struct<br>
pipe_screen *screen, enum pipe_format format)<br>
>> {<br>
>> - return si_translate_texformat(screen, format,<br>
util_format_description(format<wbr>),<br>
>> + struct util_format_description *desc =<br>
util_format_description(format<wbr>);<br>
>> + if (!desc)<br>
>> + return false;<br>
>> +<br>
>> + return si_translate_texformat(screen, format, desc,<br>
>> util_format_get_first_non_voi<wbr>d_channel(format)) != ~0U;<br>
>> }<br>
>><br>
>> @@ -1925,6 +1931,8 @@ static unsigned<br>
si_is_vertex_format_supported(<wbr>struct pipe_screen *screen,<br>
>> PIPE_BIND_VERTEX_BUFFER)) == 0);<br>
>><br>
>> desc = util_format_description(format<wbr>);<br>
>> + if (!desc)<br>
>> + return 0;<br>
>><br>
>> /* There are no native 8_8_8 or 16_16_16 data<br>
formats, and we currently<br>
>> * select 8_8_8_8 and 16_16_16_16 instead. This<br>
works reasonably well<br>
>> --<br>
>> 2.14.1<br>
>><br>
>> ______________________________<wbr>_________________<br>
>> mesa-dev mailing list<br>
>> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<mailto:<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedes<wbr>ktop.org</a>><br>
>> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
<<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org<wbr>/mailman/listinfo/mesa-dev</a>><br>
<br>
<br>
<br>
<br>
-- Best regards,<br>
Denis.<br>
<br>
</blockquote>
<br>
<br>
-- <br>
Lerne, wie die Welt wirklich ist,<br>
Aber vergiss niemals, wie sie sein sollte.<br>
</blockquote></div></div>