diff options
author | Jason Ekstrand <[email protected]> | 2016-11-29 22:19:28 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-12-02 10:53:32 -0800 |
commit | 19a541f496aace95d6660ed7e216fecc8be2e49d (patch) | |
tree | 5ce74da718bdf4c831135ba290ec781b8c0b67db /src/compiler/nir/nir_print.c | |
parent | c45d84ad8349d0c69893458d6c58eb5f6f1609c4 (diff) |
nir: Get rid of nir_constant_data
This has bothered me for about as long as NIR has been around. Why do we
have two different unions for constants? No good reason other than one of
them is a direct port from GLSL IR.
Reviewed-by: Iago Toral Quiroga <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_print.c')
-rw-r--r-- | src/compiler/nir/nir_print.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c index a5b29093c5b..eb5f57f9534 100644 --- a/src/compiler/nir/nir_print.c +++ b/src/compiler/nir/nir_print.c @@ -295,30 +295,37 @@ static void print_constant(nir_constant *c, const struct glsl_type *type, print_state *state) { FILE *fp = state->fp; - unsigned total_elems = glsl_get_components(type); - unsigned i; + const unsigned rows = glsl_get_vector_elements(type); + const unsigned cols = glsl_get_matrix_columns(type); + unsigned i, j; switch (glsl_get_base_type(type)) { case GLSL_TYPE_UINT: case GLSL_TYPE_INT: case GLSL_TYPE_BOOL: - for (i = 0; i < total_elems; i++) { - if (i > 0) fprintf(fp, ", "); - fprintf(fp, "0x%08x", c->value.u[i]); + for (i = 0; i < cols; i++) { + for (j = 0; j < rows; j++) { + if (i + j > 0) fprintf(fp, ", "); + fprintf(fp, "0x%08x", c->values[i].u32[j]); + } } break; case GLSL_TYPE_FLOAT: - for (i = 0; i < total_elems; i++) { - if (i > 0) fprintf(fp, ", "); - fprintf(fp, "%f", c->value.f[i]); + for (i = 0; i < cols; i++) { + for (j = 0; j < rows; j++) { + if (i + j > 0) fprintf(fp, ", "); + fprintf(fp, "%f", c->values[i].f32[j]); + } } break; case GLSL_TYPE_DOUBLE: - for (i = 0; i < total_elems; i++) { - if (i > 0) fprintf(fp, ", "); - fprintf(fp, "%f", c->value.d[i]); + for (i = 0; i < cols; i++) { + for (j = 0; j < rows; j++) { + if (i + j > 0) fprintf(fp, ", "); + fprintf(fp, "%f", c->values[i].f64[j]); + } } break; |