<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 21, 2016 at 5:05 AM, Samuel Iglesias Gonsálvez <span dir="ltr"><<a href="mailto:siglesias@igalia.com" target="_blank">siglesias@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">From: Iago Toral Quiroga <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>><br>
<br>
Undefined sources in alu operations don't have a valid bit size because<br>
they are uninitialized. Simply ignoring undefined sources for bit size<br>
validation is not enough since drivers can check and operate with the<br>
bit-size and that can lead to issues later on. Instead, fix undefined<br>
sources to always have a compatible bit size.<br></blockquote><div><br></div><div>I'm not sure what I think about this. I think I'd rather have undefs simply have the right bitsize.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
v2 (Sam):<br>
- Use helper to get type size from nir_alu_type.<br>
---<br>
src/compiler/nir/nir_validate.c | 10 ++++++++++<br>
1 file changed, 10 insertions(+)<br>
<br>
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c<br>
index 9f18d1c..645c15a 100644<br>
--- a/src/compiler/nir/nir_validate.c<br>
+++ b/src/compiler/nir/nir_validate.c<br>
@@ -180,9 +180,11 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state)<br>
<br>
unsigned num_components;<br>
unsigned src_bit_size;<br>
+ bool is_undef = false;<br>
if (src->src.is_ssa) {<br>
src_bit_size = src->src.ssa->bit_size;<br>
num_components = src->src.ssa->num_components;<br>
+ is_undef = src->src.ssa->parent_instr->type == nir_instr_type_ssa_undef;<br>
} else {<br>
src_bit_size = src->src.reg.reg->bit_size;<br>
if (src->src.reg.reg->is_packed)<br>
@@ -205,12 +207,20 @@ validate_alu_src(nir_alu_instr *instr, unsigned index, validate_state *state)<br>
<br>
if (nir_alu_type_get_type_size(src_type)) {<br>
/* This source has an explicit bit size */<br>
+ if (is_undef) {<br>
+ src_bit_size = nir_alu_type_get_type_size(src_type);<br>
+ src->src.ssa->bit_size = src_bit_size;<br>
+ }<br>
assert(nir_alu_type_get_type_size(src_type) == src_bit_size);<br>
} else {<br>
if (!nir_alu_type_get_type_size(nir_op_infos[instr->op].output_type)) {<br>
unsigned dest_bit_size =<br>
instr->dest.dest.is_ssa ? instr->dest.dest.ssa.bit_size<br>
: instr->dest.dest.reg.reg->bit_size;<br>
+ if (is_undef) {<br>
+ src_bit_size = dest_bit_size;<br>
+ src->src.ssa->bit_size = dest_bit_size;<br>
+ }<br>
assert(dest_bit_size == src_bit_size);<br>
}<br>
}<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>