<div dir="ltr">Thank you, i have sent new patch version.<br><br>Current call sequence in backward order:<br><br><div>r600 =><br>* r600_state_common.c::r600_translate_texformat and r600_state_common.c::r600_translate_colorformat is called from evergreen_state::r600_is_colorbuffer_format_supported and r600_state::r600_is_colorbuffer_format_supported.</div><div><br></div><div>radeonsi => </div><div> * si_state::si_translate_colorformat => si_state::si_is_colorbuffer_format_supported => si_state::si_is_format_supported (In backward sequence.)</div><div> * si_state::si_is_vertex_format_supported => si_state::si_is_format_supported</div><br>Looks as make sense to delete changes in si_translate_texformat will be enough because we check format in si_is_sampler_format_supported. <br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 11, 2017 at 5:21 PM, Nicolai Hähnle <span dir="ltr"><<a href="mailto:nhaehnle@gmail.com" target="_blank">nhaehnle@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 10.09.2017 20:52, Denis Pauk wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Bugzilla: <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>
---<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 | 13 ++++++++++++-<br>
3 files changed, 20 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u<wbr>_format.c 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 pipe_format format)<br>
boolean<br>
util_format_is_supported(enum pipe_format format, unsigned bind)<br>
{<br>
+ if (format >= PIPE_FORMAT_COUNT) {<br>
+ return FALSE;<br>
+ }<br>
+<br>
if (util_format_is_s3tc(format) && !util_format_s3tc_enabled) {<br>
return FALSE;<br>
}<br>
diff --git a/src/gallium/drivers/r600/r60<wbr>0_state_common.c 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 r600_translate_texformat(struc<wbr>t pipe_screen *screen,<br>
format = PIPE_FORMAT_A4R4_UNORM;<br>
desc = util_format_description(format<wbr>);<br>
+ if (!desc)<br>
+ goto out_unknown;<br>
/* Depth and stencil swizzling is handled separately. */<br>
if (desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) {<br>
@@ -2650,6 +2652,8 @@ uint32_t r600_translate_colorformat(enu<wbr>m chip_class chip, enum pipe_format forma<br>
const struct util_format_description *desc = util_format_description(format<wbr>);<br>
int channel = util_format_get_first_non_void<wbr>_channel(format);<br>
bool is_float;<br>
+ if (!desc)<br>
+ return ~0U;<br>
#define HAS_SIZE(x,y,z,w) \<br>
(desc->channel[0].size == (x) && desc->channel[1].size == (y) && \<br>
diff --git a/src/gallium/drivers/radeonsi<wbr>/si_state.c b/src/gallium/drivers/radeonsi<wbr>/si_state.c<br>
index ee070107fd..06fd5718fd 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 si_emit_db_render_state(struct si_context *sctx, struct r600_atom *s<br>
static uint32_t si_translate_colorformat(enum pipe_format format)<br>
{<br>
const struct util_format_description *desc = util_format_description(format<wbr>);<br>
+ if (!desc)<br>
+ return V_028C70_COLOR_INVALID;<br>
#define HAS_SIZE(x,y,z,w) \<br>
(desc->channel[0].size == (x) && desc->channel[1].size == (y) && \<br>
@@ -1442,6 +1444,9 @@ static uint32_t si_translate_texformat(struct pipe_screen *screen,<br>
bool uniform = true;<br>
int i;<br>
+ if (!desc)<br>
+ goto out_unknown;<br>
+<br>
/* Colorspace (return non-RGB formats directly). */<br>
switch (desc->colorspace) {<br>
/* Depth stencil formats */<br>
@@ -1796,7 +1801,11 @@ static unsigned si_tex_dim(struct si_screen *sscreen, struct r600_texture *rtex,<br>
static bool si_is_sampler_format_supported<wbr>(struct pipe_screen *screen, enum pipe_format format)<br>
{<br>
- return si_translate_texformat(screen, format, util_format_description(format<wbr>),<br>
+ struct util_format_description *desc = 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_void<wbr>_channel(format)) != ~0U;<br>
}<br>
@@ -1925,6 +1934,8 @@ static unsigned si_is_vertex_format_supported(<wbr>struct pipe_screen *screen,<br>
PIPE_BIND_VERTEX_BUFFER)) == 0);<br>
desc = util_format_description(format<wbr>);<br>
+ if (!desc)<br>
+ return 0;<br>
</blockquote>
<br></div></div>
The two si_is_*_format_supported hunks are fine, but all the other places should never see an invalid pipe format, so you should remove those hunks (perhaps add an assertion).<br>
<br>
Thanks,<br>
Nicolai<span class="HOEnZb"><font color="#888888"><br>
-- <br>
Lerne, wie die Welt wirklich ist,<br>
Aber vergiss niemals, wie sie sein sollte.<br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Best regards,<br> Denis.</div>
</div>