[Mesa-dev] [PATCH 16/17] glsl: Linking support for doubles (was: add double support)
Topi Pohjolainen
topi.pohjolainen at intel.com
Thu Feb 5 03:05:40 PST 2015
From: Dave Airlie <airlied at gmail.com>
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/glsl/link_uniform_initializers.cpp | 7 ++++++-
src/glsl/link_varyings.cpp | 3 ++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index f6a60bc..b4fb38f 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -75,6 +75,10 @@ copy_constant_to_storage(union gl_constant_value *storage,
case GLSL_TYPE_FLOAT:
storage[i].f = val->value.f[i];
break;
+ case GLSL_TYPE_DOUBLE:
+ storage[i * 2].u = *(uint32_t *)&val->value.d[i];
+ storage[i * 2 + 1].u = *(((uint32_t *)&val->value.d[i]) + 1);
+ break;
case GLSL_TYPE_BOOL:
storage[i].b = val->value.b[i] ? boolean_true : 0;
break;
@@ -200,6 +204,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
val->array_elements[0]->type->base_type;
const unsigned int elements = val->array_elements[0]->type->components();
unsigned int idx = 0;
+ unsigned dmul = (base_type == GLSL_TYPE_DOUBLE) ? 2 : 1;
assert(val->type->length >= storage->array_elements);
for (unsigned int i = 0; i < storage->array_elements; i++) {
@@ -209,7 +214,7 @@ set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
elements,
boolean_true);
- idx += elements;
+ idx += elements * dmul;
}
} else {
copy_constant_to_storage(storage->storage,
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index 2261799..213425c 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -868,8 +868,9 @@ varying_matches::record(ir_variable *producer_var, ir_variable *consumer_var)
: var->type->matrix_columns;
this->matches[this->num_matches].num_components = 4 * slots;
} else {
+ unsigned slot_mul = var->type->is_double() ? 2 : 1;
this->matches[this->num_matches].num_components
- = var->type->component_slots();
+ = var->type->component_slots() * slot_mul;
}
this->matches[this->num_matches].producer_var = producer_var;
this->matches[this->num_matches].consumer_var = consumer_var;
--
1.9.3
More information about the mesa-dev
mailing list