diff options
author | Matt Turner <mattst88@gmail.com> | 2017-11-08 10:36:05 -0800 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2017-11-08 10:36:05 -0800 |
commit | ce69a5a8cb609a0182a0244350079316db0ce1ab (patch) | |
tree | 9d9f8e2e6f120ab498a58a742360265481bdd09c | |
parent | 852e206f7bcf88e59bdf182518346dab3d7736e8 (diff) |
WIP for location_fracvf-component-packing
The problem is that for
layout(location = 1, component = 1) in vec3 gba[3];
layout(location = 1) in float red[3];
I'm supposed to somehow know that red[3]'s location_frac == 0 doesn't
mean "unspecified", but rather actually 0
-rw-r--r-- | src/intel/compiler/brw_nir.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 8581cdd8652..72376934581 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -218,7 +218,7 @@ brw_nir_lower_vs_inputs(nir_shader *nir, { struct { unsigned base; - unsigned components; + unsigned component_mask; } attrib[VERT_ATTRIB_MAX]; fprintf(stderr, "In %s\n", __func__); @@ -232,7 +232,8 @@ brw_nir_lower_vs_inputs(nir_shader *nir, var->data.driver_location = var->data.location; if (devinfo->gen >= 9) { - int offset = var->data.location;; + int location = var->data.location; + int location_frac = var->data.location_frac; unsigned slots = glsl_count_attribute_slots(var->type, false); unsigned components = glsl_get_component_slots(var->type); @@ -243,8 +244,12 @@ brw_nir_lower_vs_inputs(nir_shader *nir, if (glsl_type_is_64bit(glsl_without_array(var->type))) { components = ALIGN(components, 4); } + if (glsl_type_is_array(var->type) && location_frac != 0) { + components = glsl_get_component_slots(glsl_without_array(var->type)); + slots = 3; + } - unsigned component_mask = components > 4 ? 0xf : (1 << components) - 1; + unsigned component_mask = components > 4 ? 0xf : ((1 << components) - 1) << location_frac; fprintf(stderr, "Input %s, type %s, slots %d, component mask %d\n", gl_vert_attrib_name(var->data.location), @@ -252,8 +257,8 @@ brw_nir_lower_vs_inputs(nir_shader *nir, slots, component_mask); for (int i = 0; i < slots; i++) { - if ((nir->info.inputs_read & (1 << (offset + i))) != 0) { - attrib[offset + i].components = MIN2(components, 4); + if ((nir->info.inputs_read & (1 << (location + i))) != 0) { + attrib[location + i].component_mask |= component_mask; } } } @@ -261,19 +266,16 @@ brw_nir_lower_vs_inputs(nir_shader *nir, if (devinfo->gen >= 9) { for (int i = 1; i < ARRAY_SIZE(attrib); i++) { - attrib[i].base = attrib[i - 1].base + attrib[i - 1].components; + attrib[i].base = attrib[i - 1].base + + _mesa_bitcount(attrib[i - 1].component_mask); } int j = 0; for (int i = 0; i < 32; i++) { - if (attrib[i].components == 0) + if (attrib[i].component_mask == 0) continue; - if (attrib[i].components > 4) { - prog_data->component_mask[j++] = 0xf; - } else { - prog_data->component_mask[j++] = (1 << attrib[i].components) - 1; - } + prog_data->component_mask[j++] = attrib[i].component_mask; } for (; j < ARRAY_SIZE(prog_data->component_mask); j++) { |