summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_print.c
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2017-10-17 10:41:55 -0700
committerEric Anholt <[email protected]>2017-10-20 16:26:46 -0700
commit5a0d3e1129b778fd03bf1b2ad44288603283f4ec (patch)
treee00b71d9ae57d54d694b2abaedea9ae5ecce4299 /src/compiler/nir/nir_print.c
parentd9ce4ac990090b3fa940a662655b61359f296be0 (diff)
nir: Print the components referenced for split or packed shader in/outs.
Having 4 variables all called "gl_in_TexCoord0@n" isn't very informative, much better to see: decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0 (VARYING_SLOT_VAR0.x, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@0 (VARYING_SLOT_VAR0.y, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@1 (VARYING_SLOT_VAR0.z, 1, 0) decl_var shader_in INTERP_MODE_NONE float gl_in_TexCoord0@2 (VARYING_SLOT_VAR0.w, 1, 0) v2: Handle arrays and structs better (by Timothy) Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_print.c')
-rw-r--r--src/compiler/nir/nir_print.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c
index 0c21e5ba1b5..4b7ad5c6ba2 100644
--- a/src/compiler/nir/nir_print.c
+++ b/src/compiler/nir/nir_print.c
@@ -447,7 +447,31 @@ print_var_decl(nir_variable *var, print_state *state)
loc = buf;
}
- fprintf(fp, " (%s, %u, %u)%s", loc, var->data.driver_location, var->data.binding,
+ /* For shader I/O vars that have been split to components or packed,
+ * print the fractional location within the input/output.
+ */
+ unsigned int num_components =
+ glsl_get_components(glsl_without_array(var->type));
+ const char *components = NULL;
+ char components_local[6] = {'.' /* the rest is 0-filled */};
+ switch (var->data.mode) {
+ case nir_var_shader_in:
+ case nir_var_shader_out:
+ if (num_components != 4 && num_components != 0) {
+ const char *xyzw = "xyzw";
+ for (int i = 0; i < num_components; i++)
+ components_local[i + 1] = xyzw[i + var->data.location_frac];
+
+ components = components_local;
+ }
+ break;
+ default:
+ break;
+ }
+
+ fprintf(fp, " (%s%s, %u, %u)%s", loc,
+ components ? components : "",
+ var->data.driver_location, var->data.binding,
var->data.compact ? " compact" : "");
}