[Mesa-dev] [PATCH] glsl: Remove pointless uses of glsl_type::get_base_type().
Ian Romanick
idr at freedesktop.org
Thu Oct 27 11:42:28 PDT 2011
On 10/27/2011 10:48 AM, Kenneth Graunke wrote:
> These are effectively doing type->get_base_type()->base_type, which is
> equivalent to type->base_type. Just use that, as it's simpler.
>
> Signed-off-by: Kenneth Graunke<kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
> src/glsl/ir_print_visitor.cpp | 4 +---
> src/glsl/ir_reader.cpp | 6 ++----
> 2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/src/glsl/ir_print_visitor.cpp b/src/glsl/ir_print_visitor.cpp
> index b713bd0..1471355 100644
> --- a/src/glsl/ir_print_visitor.cpp
> +++ b/src/glsl/ir_print_visitor.cpp
> @@ -368,8 +368,6 @@ void ir_print_visitor::visit(ir_assignment *ir)
>
> void ir_print_visitor::visit(ir_constant *ir)
> {
> - const glsl_type *const base_type = ir->type->get_base_type();
> -
> printf("(constant ");
> print_type(ir->type);
> printf(" (");
> @@ -390,7 +388,7 @@ void ir_print_visitor::visit(ir_constant *ir)
> for (unsigned i = 0; i< ir->type->components(); i++) {
> if (i != 0)
> printf(" ");
> - switch (base_type->base_type) {
> + switch (ir->type->base_type) {
> case GLSL_TYPE_UINT: printf("%u", ir->value.u[i]); break;
> case GLSL_TYPE_INT: printf("%d", ir->value.i[i]); break;
> case GLSL_TYPE_FLOAT: printf("%f", ir->value.f[i]); break;
> diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp
> index afb06b3..3461c56 100644
> --- a/src/glsl/ir_reader.cpp
> +++ b/src/glsl/ir_reader.cpp
> @@ -773,8 +773,6 @@ ir_reader::read_constant(s_expression *expr)
> return new(mem_ctx) ir_constant(type,&elements);
> }
>
> - const glsl_type *const base_type = type->get_base_type();
> -
> ir_constant_data data = { { 0 } };
>
> // Read in list of values (at most 16).
> @@ -787,7 +785,7 @@ ir_reader::read_constant(s_expression *expr)
>
> s_expression *expr = (s_expression*) it.get();
>
> - if (base_type->base_type == GLSL_TYPE_FLOAT) {
> + if (type->base_type == GLSL_TYPE_FLOAT) {
> s_number *value = SX_AS_NUMBER(expr);
> if (value == NULL) {
> ir_read_error(values, "expected numbers");
> @@ -801,7 +799,7 @@ ir_reader::read_constant(s_expression *expr)
> return NULL;
> }
>
> - switch (base_type->base_type) {
> + switch (type->base_type) {
> case GLSL_TYPE_UINT: {
> data.u[k] = value->value();
> break;
More information about the mesa-dev
mailing list