summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/brw_nir.c
diff options
context:
space:
mode:
authorFrancisco Jerez <currojerez@riseup.net>2016-07-21 21:26:20 -0700
committerFrancisco Jerez <currojerez@riseup.net>2016-08-25 18:36:06 -0700
commit7dac8820730777756c00d7024330517848dc3b9f (patch)
tree2a229a1a650a958404b42f910971c714307efe46 /src/mesa/drivers/dri/i965/brw_nir.c
parent4e990b67cef9a90f362e5a3791234ef779f47bea (diff)
downloadexternal_mesa3d-7dac8820730777756c00d7024330517848dc3b9f.zip
external_mesa3d-7dac8820730777756c00d7024330517848dc3b9f.tar.gz
external_mesa3d-7dac8820730777756c00d7024330517848dc3b9f.tar.bz2
i965/fs: Rework representation of fragment output locations in NIR.
The problem with the current approach is that driver output locations are represented as a linear offset within the nir_outputs array, which makes it rather difficult for the back-end to figure out what color output and index some nir_intrinsic_load/store_output was meant for, because the offset of a given output within the nir_output array is dependent on the type and size of all previously allocated outputs. Instead this defines the driver location of an output to be the pair formed by its GLSL-assigned location and index (I've borrowed the bitfield macros from brw_defines.h in order to represent the pair of integers as a single scalar value that can be assigned to nir_variable_data::driver_location). nir_assign_var_locations is no longer useful for fragment outputs. Because fragment outputs are now allocated independently rather than within the nir_outputs array, the get_frag_output() helper becomes necessary in order to obtain the right temporary register for a given location-index pair. The type_size helper passed to nir_lower_io is now type_size_dvec4 rather than type_size_vec4_times_4 so that output array offsets are provided in terms of whole array elements rather than in terms of scalar components (dvec4 is the largest vector type supported by the GLSL so this will cause all individual fragment outputs to have a size of one regardless of the type). Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_nir.c')
-rw-r--r--src/mesa/drivers/dri/i965/brw_nir.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
index d12a946..24a64cb 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -339,9 +339,13 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map)
void
brw_nir_lower_fs_outputs(nir_shader *nir)
{
- nir_assign_var_locations(&nir->outputs, &nir->num_outputs,
- FRAG_RESULT_DATA0, type_size_vec4_times_4);
- nir_lower_io(nir, nir_var_shader_out, type_size_vec4_times_4);
+ nir_foreach_variable(var, &nir->outputs) {
+ var->data.driver_location =
+ SET_FIELD(var->data.index, BRW_NIR_FRAG_OUTPUT_INDEX) |
+ SET_FIELD(var->data.location, BRW_NIR_FRAG_OUTPUT_LOCATION);
+ }
+
+ nir_lower_io(nir, nir_var_shader_out, type_size_dvec4);
}
void