[Mesa-dev] [RFC 07/16] glsl: Add ubo lowering support for half floats
Topi Pohjolainen
topi.pohjolainen at intel.com
Fri May 15 02:39:34 PDT 2015
Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
src/glsl/lower_ubo_reference.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/glsl/lower_ubo_reference.cpp b/src/glsl/lower_ubo_reference.cpp
index 4ea4ccb..15e783b 100644
--- a/src/glsl/lower_ubo_reference.cpp
+++ b/src/glsl/lower_ubo_reference.cpp
@@ -516,7 +516,8 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
/* We're dereffing a column out of a row-major matrix, so we
* gather the vector from each stored row.
*/
- assert(deref->type->base_type == GLSL_TYPE_FLOAT ||
+ assert(deref->type->base_type == GLSL_TYPE_HALF ||
+ deref->type->base_type == GLSL_TYPE_FLOAT ||
deref->type->base_type == GLSL_TYPE_DOUBLE);
/* Matrices, row_major or not, are stored as if they were
* arrays of vectors of the appropriate size in std140.
@@ -527,8 +528,13 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
assert(matrix_columns <= 4);
unsigned matrix_stride = glsl_align(matrix_columns * N, 16);
- const glsl_type *ubo_type = deref->type->base_type == GLSL_TYPE_FLOAT ?
- glsl_type::float_type : glsl_type::double_type;
+ const glsl_type *ubo_type;
+ switch (deref->type->base_type) {
+ case GLSL_TYPE_HALF: ubo_type = glsl_type::hfloat_type; break;
+ case GLSL_TYPE_FLOAT: ubo_type = glsl_type::float_type; break;
+ case GLSL_TYPE_DOUBLE: ubo_type = glsl_type::double_type; break;
+ default: unreachable("Matrices are only defined for float types");
+ }
for (unsigned i = 0; i < deref->type->vector_elements; i++) {
ir_rvalue *chan_offset =
--
1.9.3
More information about the mesa-dev
mailing list