summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/glsl_to_nir.cpp
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2016-11-29 22:19:28 -0800
committerJason Ekstrand <[email protected]>2016-12-02 10:53:32 -0800
commit19a541f496aace95d6660ed7e216fecc8be2e49d (patch)
tree5ce74da718bdf4c831135ba290ec781b8c0b67db /src/compiler/glsl/glsl_to_nir.cpp
parentc45d84ad8349d0c69893458d6c58eb5f6f1609c4 (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/glsl/glsl_to_nir.cpp')
-rw-r--r--src/compiler/glsl/glsl_to_nir.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp
index 628f8de14b3..0b74b7e5aa3 100644
--- a/src/compiler/glsl/glsl_to_nir.cpp
+++ b/src/compiler/glsl/glsl_to_nir.cpp
@@ -198,34 +198,47 @@ constant_copy(ir_constant *ir, void *mem_ctx)
nir_constant *ret = ralloc(mem_ctx, nir_constant);
- unsigned total_elems = ir->type->components();
+ const unsigned rows = ir->type->vector_elements;
+ const unsigned cols = ir->type->matrix_columns;
unsigned i;
ret->num_elements = 0;
switch (ir->type->base_type) {
case GLSL_TYPE_UINT:
- for (i = 0; i < total_elems; i++)
- ret->value.u[i] = ir->value.u[i];
+ for (unsigned c = 0; c < cols; c++) {
+ for (unsigned r = 0; r < rows; r++)
+ ret->values[c].u32[r] = ir->value.u[c * rows + r];
+ }
break;
case GLSL_TYPE_INT:
- for (i = 0; i < total_elems; i++)
- ret->value.i[i] = ir->value.i[i];
+ for (unsigned c = 0; c < cols; c++) {
+ for (unsigned r = 0; r < rows; r++)
+ ret->values[c].i32[r] = ir->value.i[c * rows + r];
+ }
break;
case GLSL_TYPE_FLOAT:
- for (i = 0; i < total_elems; i++)
- ret->value.f[i] = ir->value.f[i];
+ for (unsigned c = 0; c < cols; c++) {
+ for (unsigned r = 0; r < rows; r++)
+ ret->values[c].f32[r] = ir->value.f[c * rows + r];
+ }
break;
case GLSL_TYPE_DOUBLE:
- for (i = 0; i < total_elems; i++)
- ret->value.d[i] = ir->value.d[i];
+ for (unsigned c = 0; c < cols; c++) {
+ for (unsigned r = 0; r < rows; r++)
+ ret->values[c].f64[r] = ir->value.d[c * rows + r];
+ }
break;
case GLSL_TYPE_BOOL:
- for (i = 0; i < total_elems; i++)
- ret->value.b[i] = ir->value.b[i];
+ for (unsigned c = 0; c < cols; c++) {
+ for (unsigned r = 0; r < rows; r++) {
+ ret->values[c].u32[r] = ir->value.b[c * rows + r] ?
+ NIR_TRUE : NIR_FALSE;
+ }
+ }
break;
case GLSL_TYPE_STRUCT: