diff options
author | Ian Romanick <[email protected]> | 2019-03-20 13:42:46 -0700 |
---|---|---|
committer | Ian Romanick <[email protected]> | 2019-05-14 11:38:22 -0700 |
commit | e2ad047779b02b48d35de8adaf92feed0f58aa3e (patch) | |
tree | c7fb8cd8c4f79cc2c3157c3d74e978167a0d1836 | |
parent | 5116646a7636ebc99714d1a0cc41cd402a915220 (diff) |
nir/search: Don't compare 8-bit or 1-bit constants with floats
Without this, adding an algebraic rule like
(('bcsel', ('flt', a, 0.0), 0.0, ...), ...),
will cause assertion failures inside nir_src_comp_as_float in
GTF-GL46.gtf21.GL.lessThan.lessThan_vec3_frag (and related tests) from
the OpenGL CTS and shaders/closed/steam/witcher-2/511.shader_test from
shader-db.
All of these cases have some code that ends up like
('bcsel', ('flt', a, 0.0), 'b@1', ...)
When the 'b@1' is tested, nir_src_comp_as_float fails because there's
no such thing as a 1-bit float.
Reviewed-by: Matt Turner <[email protected]>
Reviewed-by: Thomas Helland <[email protected]>
-rw-r--r-- | src/compiler/nir/nir_search.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_search.c b/src/compiler/nir/nir_search.c index 3ddda7ca332..4838825d7b4 100644 --- a/src/compiler/nir/nir_search.c +++ b/src/compiler/nir/nir_search.c @@ -326,7 +326,17 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, return false; switch (const_val->type) { - case nir_type_float: + case nir_type_float: { + nir_load_const_instr *const load = + nir_instr_as_load_const(instr->src[src].src.ssa->parent_instr); + + /* There are 8-bit and 1-bit integer types, but there are no 8-bit or + * 1-bit float types. This prevents potential assertion failures in + * nir_src_comp_as_float. + */ + if (load->def.bit_size < 16) + return false; + for (unsigned i = 0; i < num_components; ++i) { double val = nir_src_comp_as_float(instr->src[src].src, new_swizzle[i]); @@ -334,6 +344,7 @@ match_value(const nir_search_value *value, nir_alu_instr *instr, unsigned src, return false; } return true; + } case nir_type_int: case nir_type_uint: |