From 1a93fc382b18ee6d1135952d23f0b6a8aa8cd31f Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Wed, 13 Feb 2019 16:34:27 -0600 Subject: [PATCH] nir/xfb: Handle compact arrays in gather_xfb_info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes us properly handle gl_ClipDistance and gl_CullDistance. Fixes: 19064b8c "nir: Add a pass for gathering transform feedback info" Reviewed-by: Alejandro PiƱeiro --- src/compiler/nir/nir_gather_xfb_info.c | 31 +++++++++++++++++--------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/compiler/nir/nir_gather_xfb_info.c b/src/compiler/nir/nir_gather_xfb_info.c index 081ef77b48a..29e794cd4b5 100644 --- a/src/compiler/nir/nir_gather_xfb_info.c +++ b/src/compiler/nir/nir_gather_xfb_info.c @@ -37,7 +37,7 @@ add_var_xfb_outputs(nir_xfb_info *xfb, if (glsl_type_contains_64bit(type)) *offset = ALIGN_POT(*offset, 8); - if (glsl_type_is_array(type) || glsl_type_is_matrix(type)) { + if (glsl_type_is_array_or_matrix(type) && !var->data.compact) { unsigned length = glsl_get_length(type); const struct glsl_type *child_type = glsl_get_array_element(type); for (unsigned i = 0; i < length; i++) @@ -62,16 +62,27 @@ add_var_xfb_outputs(nir_xfb_info *xfb, assert(var->data.stream < NIR_MAX_XFB_STREAMS); xfb->streams_written |= (1 << var->data.stream); - unsigned comp_slots = glsl_get_component_slots(type); - unsigned attrib_slots = DIV_ROUND_UP(comp_slots, 4); - assert(attrib_slots == glsl_count_attribute_slots(type, false)); + unsigned comp_slots; + if (var->data.compact) { + /* This only happens for clip/cull which are float arrays */ + assert(glsl_without_array(type) == glsl_float_type()); + assert(var->data.location == VARYING_SLOT_CLIP_DIST0 || + var->data.location == VARYING_SLOT_CLIP_DIST1); + comp_slots = glsl_get_length(type); + } else { + comp_slots = glsl_get_component_slots(type); - /* Ensure that we don't have, for instance, a dvec2 with a location_frac - * of 2 which would make it crass a location boundary even though it - * fits in a single slot. However, you can have a dvec3 which crosses - * the slot boundary with a location_frac of 2. - */ - assert(DIV_ROUND_UP(var->data.location_frac + comp_slots, 4) == attrib_slots); + unsigned attrib_slots = DIV_ROUND_UP(comp_slots, 4); + assert(attrib_slots == glsl_count_attribute_slots(type, false)); + + /* Ensure that we don't have, for instance, a dvec2 with a + * location_frac of 2 which would make it crass a location boundary + * even though it fits in a single slot. However, you can have a + * dvec3 which crosses the slot boundary with a location_frac of 2. + */ + assert(DIV_ROUND_UP(var->data.location_frac + comp_slots, 4) == + attrib_slots); + } assert(var->data.location_frac + comp_slots <= 8); uint8_t comp_mask = ((1 << comp_slots) - 1) << var->data.location_frac;