Mesa (master): glsl: use Elements() in arrays instead of sentinal values
Module: Mesa Branch: master Commit: 84a5f27b9b7745f7f0486e067684463dd89f6b4b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=84a5f27b9b7745f7f0486e067684463dd89f6b4b Author: Brian Paul Date: Wed Jul 7 08:58:31 2010 -0600 glsl: use Elements() in arrays instead of sentinal values The _slang_*_output_name() functions had one too many loop iterations because of the sentinal end-of-list values in the vertOutput array. Just use Elements() everywhere. --- src/mesa/slang/slang_builtin.c | 40 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/mesa/slang/slang_builtin.c b/src/mesa/slang/slang_builtin.c index 95f07ef..5c1a040 100644 --- a/src/mesa/slang/slang_builtin.c +++ b/src/mesa/slang/slang_builtin.c @@ -742,8 +742,7 @@ static const struct input_info vertInputs[] = { { "gl_MultiTexCoord4", VERT_ATTRIB_TEX4, GL_FLOAT_VEC4, SWIZZLE_NOOP }, { "gl_MultiTexCoord5", VERT_ATTRIB_TEX5, GL_FLOAT_VEC4, SWIZZLE_NOOP }, { "gl_MultiTexCoord6", VERT_ATTRIB_TEX6, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_MultiTexCoord7", VERT_ATTRIB_TEX7, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { NULL, 0, GL_NONE, SWIZZLE_NOOP } + { "gl_MultiTexCoord7", VERT_ATTRIB_TEX7, GL_FLOAT_VEC4, SWIZZLE_NOOP } }; static const struct input_info geomInputs[] = { @@ -757,8 +756,7 @@ static const struct input_info geomInputs[] = { { "gl_FogFragCoordIn", GEOM_ATTRIB_FOG_FRAG_COORD, GL_FLOAT, SWIZZLE_NOOP }, { "gl_PositionIn", GEOM_ATTRIB_POSITION, GL_FLOAT_VEC4, SWIZZLE_NOOP }, { "gl_ClipVertexIn", GEOM_ATTRIB_CLIP_VERTEX, GL_FLOAT_VEC4, SWIZZLE_NOOP }, - { "gl_PointSizeIn", GEOM_ATTRIB_POINT_SIZE, GL_FLOAT, SWIZZLE_NOOP }, - { NULL, 0, GL_NONE, SWIZZLE_NOOP } + { "gl_PointSizeIn", GEOM_ATTRIB_POINT_SIZE, GL_FLOAT, SWIZZLE_NOOP } }; /** Predefined fragment shader inputs */ @@ -769,8 +767,7 @@ static const struct input_info fragInputs[] = { { "gl_TexCoord", FRAG_ATTRIB_TEX0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, { "gl_FogFragCoord", FRAG_ATTRIB_FOGC, GL_FLOAT, SWIZZLE_ }, { "gl_FrontFacing", FRAG_ATTRIB_FACE, GL_FLOAT, SWIZZLE_ }, - { "gl_PointCoord", FRAG_ATTRIB_PNTC, GL_FLOAT_VEC2, SWIZZLE_XYZW }, - { NULL, 0, GL_NONE, SWIZZLE_NOOP } + { "gl_PointCoord", FRAG_ATTRIB_PNTC, GL_FLOAT_VEC2, SWIZZLE_XYZW } }; @@ -784,17 +781,20 @@ GLint _slang_input_index(const char *name, GLenum target, GLuint *swizzleOut) { const struct input_info *inputs; - GLuint i; + GLuint i, n; switch (target) { case GL_VERTEX_PROGRAM_ARB: inputs = vertInputs; + n = Elements(vertInputs); break; case GL_FRAGMENT_PROGRAM_ARB: inputs = fragInputs; + n = Elements(fragInputs); break; case MESA_GEOMETRY_PROGRAM: inputs = geomInputs; + n = Elements(geomInputs); break; default: _mesa_problem(NULL, "bad target in _slang_input_index"); @@ -803,7 +803,7 @@ _slang_input_index(const char *name, GLenum target, GLuint *swizzleOut) ASSERT(MAX_TEXTURE_COORD_UNITS == 8); /* if this fails, fix vertInputs above */ - for (i = 0; inputs[i].Name; i++) { + for (i = 0; i < n; i++) { if (strcmp(inputs[i].Name, name) == 0) { /* found */ *swizzleOut = inputs[i].Swizzle; @@ -822,7 +822,7 @@ _slang_vert_attrib_name(GLuint attrib) { GLuint i; assert(attrib < VERT_ATTRIB_GENERIC0); - for (i = 0; vertInputs[i].Name; i++) { + for (i = 0; Elements(vertInputs); i++) { if (vertInputs[i].Attrib == attrib) return vertInputs[i].Name; } @@ -839,7 +839,7 @@ _slang_vert_attrib_type(GLuint attrib) { GLuint i; assert(attrib < VERT_ATTRIB_GENERIC0); - for (i = 0; vertInputs[i].Name; i++) { + for (i = 0; Elements(vertInputs); i++) { if (vertInputs[i].Attrib == attrib) return vertInputs[i].Type; } @@ -867,8 +867,7 @@ static const struct output_info vertOutputs[] = { { "gl_BackSecondaryColor", VERT_RESULT_BFC1, GL_FLOAT_VEC4 }, { "gl_TexCoord", VERT_RESULT_TEX0, GL_FLOAT_VEC4 }, { "gl_FogFragCoord", VERT_RESULT_FOGC, GL_FLOAT }, - { "gl_PointSize", VERT_RESULT_PSIZ, GL_FLOAT }, - { NULL, 0, GL_NONE } + { "gl_PointSize", VERT_RESULT_PSIZ, GL_FLOAT } }; /** Predefined geometry shader outputs */ @@ -883,46 +882,47 @@ static const struct output_info geomOutputs[] = { { "gl_ClipVertex", GEOM_RESULT_CLPV, GL_FLOAT_VEC4 }, { "gl_PointSize", GEOM_RESULT_PSIZ, GL_FLOAT }, { "gl_PrimitiveID", GEOM_RESULT_PRID, GL_FLOAT }, - { "gl_Layer", GEOM_RESULT_LAYR, GL_FLOAT }, - { NULL, 0, GL_NONE } + { "gl_Layer", GEOM_RESULT_LAYR, GL_FLOAT } }; /** Predefined fragment shader outputs */ static const struct output_info fragOutputs[] = { { "gl_FragColor", FRAG_RESULT_COLOR, GL_FLOAT_VEC4 }, { "gl_FragDepth", FRAG_RESULT_DEPTH, GL_FLOAT }, - { "gl_FragData", FRAG_RESULT_DATA0, GL_FLOAT_VEC4 }, - { NULL, 0, GL_NONE } + { "gl_FragData", FRAG_RESULT_DATA0, GL_
Mesa (glsl2): glsl2: Avoid null deref in scalar constant unop expressions.
Module: Mesa Branch: glsl2 Commit: 570dc0d4004bf09d257b3e4c8664d3c26a8af510 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=570dc0d4004bf09d257b3e4c8664d3c26a8af510 Author: Eric Anholt Date: Wed Jul 7 09:07:09 2010 -0700 glsl2: Avoid null deref in scalar constant unop expressions. --- src/glsl/ir_constant_expression.cpp |7 ++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 541398a..98cbb6c 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -151,7 +151,12 @@ ir_constant_visitor::visit(ir_expression *ir) */ unsigned c0_inc = op0_scalar ? 1 : 0; unsigned c1_inc = op1_scalar ? 1 : 0; - unsigned components = op[op1_scalar ? 0 : 1]->type->components(); + unsigned components; + if (op1_scalar || !op[1]) { + components = op[0]->type->components(); + } else { + components = op[1]->type->components(); + } switch (ir->operation) { case ir_unop_logic_not: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Don' t forget to walk the parameters to a function in the hv.
Module: Mesa Branch: glsl2 Commit: 773025b92c934014b9ceb4ebfdabcfc9d8587aa2 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=773025b92c934014b9ceb4ebfdabcfc9d8587aa2 Author: Eric Anholt Date: Wed Jul 7 08:38:16 2010 -0700 glsl2: Don't forget to walk the parameters to a function in the hv. Fixes segfaults from use after free after the steal of ir nodes and free of the compile context. --- src/glsl/ir_hv_accept.cpp |4 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/src/glsl/ir_hv_accept.cpp b/src/glsl/ir_hv_accept.cpp index e772018..1a88c59 100644 --- a/src/glsl/ir_hv_accept.cpp +++ b/src/glsl/ir_hv_accept.cpp @@ -116,6 +116,10 @@ ir_function_signature::accept(ir_hierarchical_visitor *v) if (s != visit_continue) return (s == visit_continue_with_parent) ? visit_continue : s; + s = visit_list_elements(v, &this->parameters); + if (s == visit_stop) + return s; + s = visit_list_elements(v, &this->body); return (s == visit_stop) ? s : v->visit_leave(this); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Clean up vec_index_to_cond_assign after the clone return type change.
Module: Mesa Branch: glsl2 Commit: 6de882334ac7f3d32d04261adfed1397e075ffd5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6de882334ac7f3d32d04261adfed1397e075ffd5 Author: Eric Anholt Date: Wed Jul 7 08:39:09 2010 -0700 glsl2: Clean up vec_index_to_cond_assign after the clone return type change. --- src/glsl/ir_vec_index_to_cond_assign.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_vec_index_to_cond_assign.cpp b/src/glsl/ir_vec_index_to_cond_assign.cpp index 6264a43..3f527fc 100644 --- a/src/glsl/ir_vec_index_to_cond_assign.cpp +++ b/src/glsl/ir_vec_index_to_cond_assign.cpp @@ -107,8 +107,8 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue /* Just clone the rest of the deref chain when trying to get at the * underlying variable. */ - deref = (ir_dereference *)orig_deref->array->clone(NULL); - swizzle = new(base_ir) ir_swizzle(deref, i, 0, 0, 0, 1); + swizzle = new(base_ir) ir_swizzle(orig_deref->array->clone(NULL), + i, 0, 0, 0, 1); deref = new(base_ir) ir_dereference_variable(var); assign = new(base_ir) ir_assignment(deref, swizzle, condition); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Add a pass to simplify if statements returning from both sides.
Module: Mesa Branch: glsl2 Commit: d674ebcee0d2731e50d6530502cefcebc39dcdb6 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d674ebcee0d2731e50d6530502cefcebc39dcdb6 Author: Eric Anholt Date: Tue Jul 6 18:09:39 2010 -0700 glsl2: Add a pass to simplify if statements returning from both sides. This allows function inlining making the following tests work even without function calls implemented: glsl-fs-functions-2 glsl-fs-functions-3 glsl-vs-functions glsl-vs-functions-2 glsl-vs-functions-3 glsl-vs-vec4-indexing-5 (Note that those tests were designed to trigger actual function calls, and this defeats them. However, those testcases ended up catching the bug in the previous commit.) --- src/glsl/Makefile |1 + src/glsl/ir_if_return.cpp | 123 src/glsl/ir_optimization.h |1 + src/mesa/shader/ir_to_mesa.cpp |1 + 4 files changed, 126 insertions(+), 0 deletions(-) diff --git a/src/glsl/Makefile b/src/glsl/Makefile index d2a687a..ddc9d82 100644 --- a/src/glsl/Makefile +++ b/src/glsl/Makefile @@ -40,6 +40,7 @@ CXX_SOURCES = \ ir_function_inlining.cpp \ ir_hierarchical_visitor.cpp \ ir_hv_accept.cpp \ + ir_if_return.cpp \ ir_if_simplification.cpp \ ir_mod_to_fract.cpp \ ir_print_visitor.cpp \ diff --git a/src/glsl/ir_if_return.cpp b/src/glsl/ir_if_return.cpp new file mode 100644 index 000..f68dcfb --- /dev/null +++ b/src/glsl/ir_if_return.cpp @@ -0,0 +1,123 @@ +/* + * Copyright © 2010 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file ir_if_return.cpp + * + * If a function includes an if statement that returns from both + * branches, then make the branches write the return val to a temp and + * return the temp after the if statement. + * + * This allows inlinining in the common case of short functions that + * return one of two values based on a condition. This helps on + * hardware with no branching support, and may even be a useful + * transform on hardware supporting control flow by masked returns + * with normal returns. + */ + +#include "ir.h" + +class ir_if_return_visitor : public ir_hierarchical_visitor { +public: + ir_if_return_visitor() + { + this->progress = false; + } + + ir_visitor_status visit_enter(ir_if *); + + bool progress; +}; + +bool +do_if_return(exec_list *instructions) +{ + ir_if_return_visitor v; + + visit_list_elements(&v, instructions); + + return v.progress; +} + + +ir_visitor_status +ir_if_return_visitor::visit_enter(ir_if *ir) +{ + ir_return *then_return = NULL; + ir_return *else_return = NULL; + + /* Try to find a return statement on both sides. */ + foreach_iter(exec_list_iterator, then_iter, ir->then_instructions) { + ir_instruction *then_ir = (ir_instruction *)then_iter.get(); + then_return = then_ir->as_return(); + if (then_return) +break; + } + if (!then_return) + return visit_continue; + + foreach_iter(exec_list_iterator, else_iter, ir->else_instructions) { + ir_instruction *else_ir = (ir_instruction *)else_iter.get(); + else_return = else_ir->as_return(); + if (else_return) +break; + } + if (!else_return) + return visit_continue; + + /* Trim off any trailing instructions after the return statements +* on both sides. +*/ + while (then_return->get_next()->get_next()) + ((ir_instruction *)then_return->get_next())->remove(); + while (else_return->get_next()->get_next()) + ((ir_instruction *)else_return->get_next())->remove(); + + this->progress = true; + + if (!then_return->value) { + then_return->remove(); + else_return->remove(); + ir->insert_after(new(ir) ir_return(NULL)); + } else { + ir_assignment *assign; + ir_variable *new_var = new(ir) ir_variable(then_return->value->type, +
Mesa (master): demos: set version to 8.0
Module: Mesa Branch: master Commit: b78cd1854643fea9fafb40f0034a35bbc9509fb8 URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=b78cd1854643fea9fafb40f0034a35bbc9509fb8 Author: Jerome Glisse Date: Wed Jul 7 14:17:49 2010 -0400 demos: set version to 8.0 Hoping that demos version 8.0 won't confuse much the end user while easing the work for distro. --- configure.ac |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 1035494..12192de 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ dnl Process this file with autoconf to create configure. AC_PREREQ([2.59]) -AC_INIT([mesa-demos], [7.7], +AC_INIT([mesa-demos], [8.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa]) AC_CANONICAL_HOST ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): r600: workaround 3 comp GL_SHORT vertex attribute format on r700
Module: Mesa Branch: master Commit: 51c438feb765cf03d1a6448295e6c62be61a5e56 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=51c438feb765cf03d1a6448295e6c62be61a5e56 Author: Andre Maasikas Date: Wed Jul 7 21:32:07 2010 +0300 r600: workaround 3 comp GL_SHORT vertex attribute format on r700 guess it's a hw errata? --- src/mesa/drivers/dri/r600/r700_assembler.c |4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index 88d6b06..ffc2d14 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -293,7 +293,9 @@ GLuint GetSurfaceFormat(GLenum eType, GLuint nChannels, GLuint * pClient_size) case 2: format = FMT_16_16; break; case 3: -format = FMT_16_16_16; break; +/* 3 comp GL_SHORT vertex format doesnt work on r700 + 4 somehow works, test - sauerbraten */ +format = FMT_16_16_16_16; break; case 4: format = FMT_16_16_16_16; break; default: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Fill in some uninitialized fields that sometimes contained junk.
Module: Mesa Branch: glsl2 Commit: 8bb15c1ed55eb71533d2af94a6afbf01e3d23610 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8bb15c1ed55eb71533d2af94a6afbf01e3d23610 Author: Eric Anholt Date: Wed Jul 7 11:38:55 2010 -0700 ir_to_mesa: Fill in some uninitialized fields that sometimes contained junk. --- src/mesa/shader/ir_to_mesa.cpp |6 -- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 260..d179692 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -192,11 +192,11 @@ ir_to_mesa_src_reg ir_to_mesa_undef = { }; ir_to_mesa_dst_reg ir_to_mesa_undef_dst = { - PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP + PROGRAM_UNDEFINED, 0, SWIZZLE_NOOP, COND_TR }; ir_to_mesa_dst_reg ir_to_mesa_address_reg = { - PROGRAM_ADDRESS, 0, WRITEMASK_X + PROGRAM_ADDRESS, 0, WRITEMASK_X, COND_TR }; static int swizzle_for_size(int size) @@ -375,6 +375,8 @@ ir_to_mesa_visitor::src_reg_for_float(float val) src_reg.file = PROGRAM_CONSTANT; src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, &val, 1, &src_reg.swizzle); + src_reg.reladdr = GL_FALSE; + src_reg.negate = 0; return src_reg; } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Add support for gl_TextureMatrix access.
Module: Mesa Branch: glsl2 Commit: 76101f7c0468c7f346b1a8d6b824fc8914a17bd1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=76101f7c0468c7f346b1a8d6b824fc8914a17bd1 Author: Eric Anholt Date: Wed Jul 7 11:39:48 2010 -0700 ir_to_mesa: Add support for gl_TextureMatrix access. Fixes glsl-vs-texturematrix-1, and glsl-vs-texturematrix-2 on swrast. --- src/mesa/shader/ir_to_mesa.cpp | 103 --- 1 files changed, 84 insertions(+), 19 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index d179692..21b01ed 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -869,8 +869,34 @@ ir_to_mesa_visitor::visit(ir_swizzle *ir) this->result = src_reg; } +static int +add_matrix_ref(struct gl_program *prog, int *tokens) +{ + int base_pos = -1; + int i; + + /* Add a ref for each column. It looks like the reason we do +* it this way is that _mesa_add_state_reference doesn't work +* for things that aren't vec4s, so the tokens[2]/tokens[3] +* range has to be equal. +*/ + for (i = 0; i < 4; i++) { + tokens[2] = i; + tokens[3] = i; + int pos = _mesa_add_state_reference(prog->Parameters, + (gl_state_index *)tokens); + if (base_pos == -1) +base_pos = pos; + else +assert(base_pos + i == pos); + } + + return base_pos; +} + static temp_entry * -get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var) +get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var, + ir_rvalue *array_index) { /* * NOTE: The ARB_vertex_program extension specified that matrices get @@ -915,28 +941,31 @@ get_builtin_matrix_ref(void *mem_ctx, struct gl_program *prog, ir_variable *var) for (i = 0; i < Elements(matrices); i++) { if (strcmp(var->name, matrices[i].name) == 0) { -int j; -int last_pos = -1, base_pos = -1; int tokens[STATE_LENGTH]; +int base_pos = -1; tokens[0] = matrices[i].matrix; -tokens[1] = 0; /* array index! */ tokens[4] = matrices[i].modifier; - -/* Add a ref for each column. It looks like the reason we do - * it this way is that _mesa_add_state_reference doesn't work - * for things that aren't vec4s, so the tokens[2]/tokens[3] - * range has to be equal. - */ -for (j = 0; j < 4; j++) { - tokens[2] = j; - tokens[3] = j; - int pos = _mesa_add_state_reference(prog->Parameters, - (gl_state_index *)tokens); - assert(last_pos == -1 || last_pos == base_pos + j); - if (base_pos == -1) - base_pos = pos; +if (matrices[i].matrix == STATE_TEXTURE_MATRIX) { + ir_constant *index = array_index->constant_expression_value(); + if (index) { + tokens[1] = index->value.i[0]; + base_pos = add_matrix_ref(prog, tokens); + } else { + for (i = 0; i < var->type->length; i++) { + tokens[1] = i; + int pos = add_matrix_ref(prog, tokens); + if (base_pos == -1) +base_pos = pos; + else +assert(base_pos + (int)i * 4 == pos); + } + } +} else { + tokens[1] = 0; /* unused array index */ + base_pos = add_matrix_ref(prog, tokens); } +tokens[4] = matrices[i].modifier; entry = new(mem_ctx) temp_entry(var, PROGRAM_STATE_VAR, @@ -959,7 +988,8 @@ ir_to_mesa_visitor::visit(ir_dereference_variable *ir) if (!entry) { switch (ir->var->mode) { case ir_var_uniform: -entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var); +entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, ir->var, + NULL); if (entry) break; @@ -1057,9 +1087,44 @@ ir_to_mesa_visitor::visit(ir_dereference_array *ir) { ir_constant *index; ir_to_mesa_src_reg src_reg; + ir_dereference_variable *deref_var = ir->array->as_dereference_variable(); index = ir->array_index->constant_expression_value(); + if (deref_var && strncmp(deref_var->var->name, + "gl_TextureMatrix", + strlen("gl_TextureMatrix")) == 0) { + ir_to_mesa_src_reg src_reg; + struct temp_entry *entry; + + entry = get_builtin_matrix_ref(this->mem_ctx, this->prog, deref_var->var, +ir->array_index); + assert(entry); + + src_reg.file = entry->file; + src_reg.index = entry->index; + src_reg.swizzle = swizzle_for_size(ir->type->vector_elements); + src_reg.negate = 0; + + if (in
Mesa (master): st/mesa: fix sampler max_lod computation
Module: Mesa Branch: master Commit: 9755539116fd0b818cc0636a6d6ed10b19b639be URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9755539116fd0b818cc0636a6d6ed10b19b639be Author: Brian Paul Date: Wed Jul 7 13:04:47 2010 -0600 st/mesa: fix sampler max_lod computation This change makes gallium behave like other GL implementations and fixes a conformance failure. --- src/mesa/state_tracker/st_atom_sampler.c |3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 92fe72d..f147d76 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -199,7 +199,8 @@ update_samplers(struct st_context *st) if (sampler->min_lod < texobj->BaseLevel) sampler->min_lod = texobj->BaseLevel; - sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel, texobj->MaxLod); + sampler->max_lod = MIN2((GLfloat) texobj->MaxLevel, + (texobj->MaxLod + texobj->BaseLevel)); if (sampler->max_lod < sampler->min_lod) { /* The GL spec doesn't seem to specify what to do in this case. * Swap the values. ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): exec_list: Add method to append one complete list to another
Module: Mesa Branch: glsl2 Commit: c44556317abf77ca6e344c79d119c91bebe25c8c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c44556317abf77ca6e344c79d119c91bebe25c8c Author: Ian Romanick Date: Wed Jul 7 12:12:48 2010 -0700 exec_list: Add method to append one complete list to another --- src/glsl/list.h | 24 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/src/glsl/list.h b/src/glsl/list.h index d449bdd..b5a413d 100644 --- a/src/glsl/list.h +++ b/src/glsl/list.h @@ -385,6 +385,30 @@ struct exec_list { } } + /** +* Append all nodes from the source list to the target list +*/ + void + append_list(exec_list *source) + { + if (source->is_empty()) +return; + + /* Link the first node of the source with the last node of the target list. + */ + this->tail_pred->next = source->head; + source->head->prev = this->tail_pred; + + /* Make the tail of the source list be the tail of the target list. + */ + this->tail_pred = source->tail_pred; + this->tail_pred->next = (exec_node *) &this->tail; + + /* Make the source list empty for good measure. + */ + source->make_empty(); + } + exec_list_iterator iterator() { return exec_list_iterator(head); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): Revert "glsl2: Put the declaration in the instruction stream before its initializer."
Module: Mesa Branch: glsl2 Commit: 2e85f993d8a014b53ad2f6d295cf66d3fb38b091 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2e85f993d8a014b53ad2f6d295cf66d3fb38b091 Author: Ian Romanick Date: Wed Jul 7 11:57:16 2010 -0700 Revert "glsl2: Put the declaration in the instruction stream before its initializer." This change causes segfaults in other tests. A fix for both sets of segfaults is coming. This reverts commit d4d630b72c7b7f38074addda0f1b819608247d93. --- src/glsl/ast_to_hir.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index 3de754f..f5e93b0 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1772,8 +1772,6 @@ ast_declarator_list::hir(exec_list *instructions, } } - instructions->push_tail(var); - if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1920,6 +1918,8 @@ ast_declarator_list::hir(exec_list *instructions, decl->identifier); } + instructions->push_tail(var); + /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL * specification. From page 28 (page 34 of the PDF) of the GLSL 1.50 ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Initialize yylineno and yycolumn so line numbers are sane.
Module: Mesa Branch: glsl2 Commit: 388ab9fa6b468d8c162dd4fc645d2f758c49051c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=388ab9fa6b468d8c162dd4fc645d2f758c49051c Author: Kenneth Graunke Date: Wed Jul 7 11:40:51 2010 -0700 glsl2: Initialize yylineno and yycolumn so line numbers are sane. --- src/glsl/glcpp/glcpp-lex.l |1 + src/glsl/glsl_lexer.lpp|2 ++ 2 files changed, 3 insertions(+), 0 deletions(-) diff --git a/src/glsl/glcpp/glcpp-lex.l b/src/glsl/glcpp/glcpp-lex.l index 6a91b09..53e8555 100644 --- a/src/glsl/glcpp/glcpp-lex.l +++ b/src/glsl/glcpp/glcpp-lex.l @@ -36,6 +36,7 @@ yylloc->first_line = yylineno;\ yycolumn += yyleng; \ } while(0); +#define YY_USER_INIT yylineno = 0; yycolumn = 0; %} %option bison-bridge bison-locations reentrant noyywrap diff --git a/src/glsl/glsl_lexer.lpp b/src/glsl/glsl_lexer.lpp index ddaa19d..6c10008 100644 --- a/src/glsl/glsl_lexer.lpp +++ b/src/glsl/glsl_lexer.lpp @@ -34,6 +34,8 @@ yycolumn += yyleng; \ } while(0); +#define YY_USER_INIT yylineno = 0; yycolumn = 0; + %} %option bison-bridge bison-locations reentrant noyywrap ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_constant_expression: Fix loop increments.
Module: Mesa Branch: glsl2 Commit: acf88f2769c15c9185abe5bd76a885218f431e58 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=acf88f2769c15c9185abe5bd76a885218f431e58 Author: Kenneth Graunke Date: Wed Jul 7 12:08:23 2010 -0700 ir_constant_expression: Fix loop increments. --- src/glsl/ir_constant_expression.cpp |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp index 98cbb6c..0fe93ad 100644 --- a/src/glsl/ir_constant_expression.cpp +++ b/src/glsl/ir_constant_expression.cpp @@ -149,8 +149,8 @@ ir_constant_visitor::visit(ir_expression *ir) /* When iterating over a vector or matrix's components, we want to increase * the loop counter. However, for scalars, we want to stay at 0. */ - unsigned c0_inc = op0_scalar ? 1 : 0; - unsigned c1_inc = op1_scalar ? 1 : 0; + unsigned c0_inc = op0_scalar ? 0 : 1; + unsigned c1_inc = op1_scalar ? 0 : 1; unsigned components; if (op1_scalar || !op[1]) { components = op[0]->type->components(); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Put the initializer in the instruction stream after the declaration
Module: Mesa Branch: glsl2 Commit: e78e0fa42b49b50ed1150f7fdb74bf942ebd6bcf URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e78e0fa42b49b50ed1150f7fdb74bf942ebd6bcf Author: Ian Romanick Date: Wed Jul 7 12:13:34 2010 -0700 glsl2: Put the initializer in the instruction stream after the declaration --- src/glsl/ast_to_hir.cpp | 13 +++-- 1 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index f5e93b0..b21131f 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -1772,6 +1772,13 @@ ast_declarator_list::hir(exec_list *instructions, } } + /* Process the initializer and add its instructions to a temporary + * list. This list will be added to the instruction stream (below) after + * the declaration is added. This is done because in some cases (such as + * redeclarations) the declaration may not actually be added to the + * instruction stream. + */ + exec_list intializer_instructions; if (decl->initializer != NULL) { YYLTYPE initializer_loc = decl->initializer->get_location(); @@ -1801,7 +1808,8 @@ ast_declarator_list::hir(exec_list *instructions, } ir_dereference *const lhs = new(ctx) ir_dereference_variable(var); -ir_rvalue *rhs = decl->initializer->hir(instructions, state); +ir_rvalue *rhs = decl->initializer->hir(&intializer_instructions, +state); /* Calculate the constant value if this is a const or uniform * declaration. @@ -1829,7 +1837,7 @@ ast_declarator_list::hir(exec_list *instructions, /* Never emit code to initialize a uniform. */ if (!this->type->qualifier.uniform) - result = do_assignment(instructions, state, lhs, rhs, + result = do_assignment(&intializer_instructions, state, lhs, rhs, this->get_location()); var->read_only = temp; } @@ -1919,6 +1927,7 @@ ast_declarator_list::hir(exec_list *instructions, } instructions->push_tail(var); + instructions->append_list(&intializer_instructions); /* Add the variable to the symbol table after processing the initializer. * This differs from most C-like languages, but it follows the GLSL ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Fix ir_div_to_mul_rcp for integer division.
Module: Mesa Branch: glsl2 Commit: 9cbd8a1d5a85f39f12e9edbd2defbb9e9d0468ef URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9cbd8a1d5a85f39f12e9edbd2defbb9e9d0468ef Author: Eric Anholt Date: Wed Jul 7 12:25:22 2010 -0700 glsl2: Fix ir_div_to_mul_rcp for integer division. rcp of an integer value did not produce the result you're looking for. Instead, do the a * rcp(b) as float and truncate after. This mostly fixes glsl-fs-loop-nested. --- src/glsl/ir_div_to_mul_rcp.cpp | 56 +-- 1 files changed, 47 insertions(+), 9 deletions(-) diff --git a/src/glsl/ir_div_to_mul_rcp.cpp b/src/glsl/ir_div_to_mul_rcp.cpp index ce84add..640d5d6 100644 --- a/src/glsl/ir_div_to_mul_rcp.cpp +++ b/src/glsl/ir_div_to_mul_rcp.cpp @@ -33,6 +33,7 @@ */ #include "ir.h" +#include "glsl_types.h" class ir_div_to_mul_rcp_visitor : public ir_hierarchical_visitor { public: @@ -61,16 +62,53 @@ ir_div_to_mul_rcp_visitor::visit_leave(ir_expression *ir) if (ir->operation != ir_binop_div) return visit_continue; - /* New expression for the 1.0 / op1 */ - ir_rvalue *expr; - expr = new(ir) ir_expression(ir_unop_rcp, - ir->operands[1]->type, - ir->operands[1], - NULL); + if (ir->operands[1]->type->base_type != GLSL_TYPE_INT && + ir->operands[1]->type->base_type != GLSL_TYPE_UINT) { + /* New expression for the 1.0 / op1 */ + ir_rvalue *expr; + expr = new(ir) ir_expression(ir_unop_rcp, + ir->operands[1]->type, + ir->operands[1], + NULL); + + /* op0 / op1 -> op0 * (1.0 / op1) */ + ir->operation = ir_binop_mul; + ir->operands[1] = expr; + } else { + /* Be careful with integer division -- we need to do it as a + * float and re-truncate, since rcp(n > 1) of an integer would + * just be 0. + */ + ir_rvalue *op0, *op1; + const struct glsl_type *vec_type; + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, +ir->operands[1]->type->vector_elements, +ir->operands[1]->type->matrix_columns); + + if (ir->operands[1]->type->base_type == GLSL_TYPE_INT) +op1 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[1], NULL); + else +op1 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[1], NULL); + + op1 = new(ir) ir_expression(ir_unop_rcp, op1->type, op1, NULL); + + vec_type = glsl_type::get_instance(GLSL_TYPE_FLOAT, +ir->operands[0]->type->vector_elements, +ir->operands[0]->type->matrix_columns); + + if (ir->operands[0]->type->base_type == GLSL_TYPE_INT) +op0 = new(ir) ir_expression(ir_unop_i2f, vec_type, ir->operands[0], NULL); + else +op0 = new(ir) ir_expression(ir_unop_u2f, vec_type, ir->operands[0], NULL); + + op0 = new(ir) ir_expression(ir_binop_mul, vec_type, op0, op1); + + ir->operation = ir_unop_f2i; + ir->operands[0] = op0; + ir->operands[1] = NULL; + } - /* op0 / op1 -> op0 * (1.0 / op1) */ - ir->operation = ir_binop_mul; - ir->operands[1] = expr; this->made_progress = true; return visit_continue; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Actually add the declaration of _post_incdec_temp.
Module: Mesa Branch: glsl2 Commit: 43b5b03d67ce890e867c81d4a5cfc4871d711d43 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=43b5b03d67ce890e867c81d4a5cfc4871d711d43 Author: Eric Anholt Date: Wed Jul 7 14:04:30 2010 -0700 glsl2: Actually add the declaration of _post_incdec_temp. --- src/glsl/ast_to_hir.cpp |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp index b21131f..e716b8a 100644 --- a/src/glsl/ast_to_hir.cpp +++ b/src/glsl/ast_to_hir.cpp @@ -571,6 +571,7 @@ get_lvalue_copy(exec_list *instructions, ir_rvalue *lvalue) /* FINISHME: Give unique names to the temporaries. */ var = new(ctx) ir_variable(lvalue->type, "_post_incdec_tmp"); + instructions->push_tail(var); var->mode = ir_var_auto; instructions->push_tail(new(ctx) ir_assignment(new(ctx) ir_dereference_variable(var), ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl: Fix the setup of refract()'s output for vec3/ vec4 and k < 0.0.
Module: Mesa Branch: glsl2 Commit: 0b74bbb3dcf07489e1dbd1976f07093ad7821e51 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0b74bbb3dcf07489e1dbd1976f07093ad7821e51 Author: Eric Anholt Date: Wed Jul 7 14:53:43 2010 -0700 glsl: Fix the setup of refract()'s output for vec3/vec4 and k < 0.0. caught by valgrind. --- src/glsl/builtin_function.cpp |4 ++-- src/glsl/builtins/110/refract |4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/glsl/builtin_function.cpp b/src/glsl/builtin_function.cpp index 40c85e7..5b3b49d 100644 --- a/src/glsl/builtin_function.cpp +++ b/src/glsl/builtin_function.cpp @@ -1808,7 +1808,7 @@ static const char *builtins_110_refract = { " (expression float dot (var_ref n) (var_ref i))\n" " (expression float dot (var_ref n) (var_ref i\n" " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec3 (0.0 0.0\n" + " ((return (constant vec3 (0.0 0.0 0.0\n" " ((return (expression vec3 -\n" "(expression vec3 * (var_ref eta) (var_ref i))\n" "(expression vec3 *\n" @@ -1833,7 +1833,7 @@ static const char *builtins_110_refract = { " (expression float dot (var_ref n) (var_ref i))\n" " (expression float dot (var_ref n) (var_ref i\n" " (if (expression bool < (var_ref k) (constant float (0.0)))\n" - " ((return (constant vec4 (0.0 0.0\n" + " ((return (constant vec4 (0.0 0.0 0.0 0.0\n" " ((return (expression vec4 -\n" "(expression vec4 * (var_ref eta) (var_ref i))\n" "(expression vec4 *\n" diff --git a/src/glsl/builtins/110/refract b/src/glsl/builtins/110/refract index e9b1475..522ab41 100644 --- a/src/glsl/builtins/110/refract +++ b/src/glsl/builtins/110/refract @@ -64,7 +64,7 @@ (expression float dot (var_ref n) (var_ref i)) (expression float dot (var_ref n) (var_ref i (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec3 (0.0 0.0 + ((return (constant vec3 (0.0 0.0 0.0 ((return (expression vec3 - (expression vec3 * (var_ref eta) (var_ref i)) (expression vec3 * @@ -89,7 +89,7 @@ (expression float dot (var_ref n) (var_ref i)) (expression float dot (var_ref n) (var_ref i (if (expression bool < (var_ref k) (constant float (0.0))) - ((return (constant vec4 (0.0 0.0 + ((return (constant vec4 (0.0 0.0 0.0 0.0 ((return (expression vec4 - (expression vec4 * (var_ref eta) (var_ref i)) (expression vec4 * ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): linker: Use bit-0 instead of VERT_BIT_GENERIC0
Module: Mesa Branch: glsl2 Commit: 35c89204e597e6d4d3e8b8c665ce1c51d6dde4d7 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=35c89204e597e6d4d3e8b8c665ce1c51d6dde4d7 Author: Ian Romanick Date: Wed Jul 7 16:28:39 2010 -0700 linker: Use bit-0 instead of VERT_BIT_GENERIC0 Uses of the bits for allocation are offset by 16, and VERT_BIT_GENERIC0 already has the 16 offset. As a result, it was preventing the wrong thing from being allocated. --- src/glsl/linker.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp index 5227d42..eb10f90 100644 --- a/src/glsl/linker.cpp +++ b/src/glsl/linker.cpp @@ -667,7 +667,7 @@ assign_attribute_locations(gl_shader_program *prog, unsigned max_attribute_index * be explicitly assigned by via glBindAttribLocation. Mark it as reserved * to prevent it from being automatically allocated below. */ - used_locations |= VERT_BIT_GENERIC0; + used_locations |= (1 << 0); for (unsigned i = 0; i < num_attr; i++) { /* Mask representing the contiguous slots that will be used by this ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): gallivm: fix cube map LOD computation
Module: Mesa Branch: master Commit: b17fba92dbee3a91c7854cb2935fa1e6be81982d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b17fba92dbee3a91c7854cb2935fa1e6be81982d Author: Brian Paul Date: Wed Jul 7 17:27:10 2010 -0600 gallivm: fix cube map LOD computation First, this undoes commit e503af4baa2c709ae5743bb278b277d3faaba076 so we use iround() in lp_build_nearest_mip_level(). Second, in lp_build_sample_general() we need to check if we're sampling a cube map before anything else. Choose the cube face and then recompute the partial derivatives of (S,T) with respect to the chosen cube face. Before, we were using the directional (S,T,R) derivatives to compute the LOD. Third, work around an apparent bug in LLVM 2.7 where setting the lod variable to a const(0) value results in bad x86 code. See comments in the code. --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c | 92 - 1 files changed, 54 insertions(+), 38 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 7baf5b6..0e24ecf 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -53,6 +53,7 @@ #include "lp_bld_gather.h" #include "lp_bld_format.h" #include "lp_bld_sample.h" +#include "lp_bld_quad.h" /** @@ -818,9 +819,8 @@ lp_build_minify(struct lp_build_sample_context *bld, /** * Generate code to compute texture level of detail (lambda). - * \param s vector of texcoord s values - * \param t vector of texcoord t values - * \param r vector of texcoord r values + * \param ddx partial derivatives of (s, t, r, q) with respect to X + * \param ddy partial derivatives of (s, t, r, q) with respect to Y * \param lod_bias optional float vector with the shader lod bias * \param explicit_lod optional float vector with the explicit lod * \param width scalar int texture width @@ -832,11 +832,8 @@ lp_build_minify(struct lp_build_sample_context *bld, */ static LLVMValueRef lp_build_lod_selector(struct lp_build_sample_context *bld, - LLVMValueRef s, - LLVMValueRef t, - LLVMValueRef r, - const LLVMValueRef *ddx, - const LLVMValueRef *ddy, + const LLVMValueRef ddx[4], + const LLVMValueRef ddy[4], LLVMValueRef lod_bias, /* optional */ LLVMValueRef explicit_lod, /* optional */ LLVMValueRef width, @@ -871,14 +868,6 @@ lp_build_lod_selector(struct lp_build_sample_context *bld, LLVMValueRef dtdx = NULL, dtdy = NULL, drdx = NULL, drdy = NULL; LLVMValueRef rho; - /* - * dsdx = abs(s[1] - s[0]); - * dsdy = abs(s[2] - s[0]); - * dtdx = abs(t[1] - t[0]); - * dtdy = abs(t[2] - t[0]); - * drdx = abs(r[1] - r[0]); - * drdy = abs(r[2] - r[0]); - */ dsdx = LLVMBuildExtractElement(bld->builder, ddx[0], index0, "dsdx"); dsdx = lp_build_abs(float_bld, dsdx); dsdy = LLVMBuildExtractElement(bld->builder, ddy[0], index0, "dsdy"); @@ -961,7 +950,7 @@ lp_build_nearest_mip_level(struct lp_build_sample_context *bld, bld->builder, unit); /* convert float lod to integer */ - level = lp_build_itrunc(float_bld, lod); + level = lp_build_iround(float_bld, lod); /* clamp level to legal range of levels */ *level_out = lp_build_clamp(int_bld, level, zero, last_level); @@ -1288,7 +1277,7 @@ lp_build_cube_face(struct lp_build_sample_context *bld, /** - * Generate code to do cube face selection and per-face texcoords. + * Generate code to do cube face selection and compute per-face texcoords. */ static void lp_build_cube_lookup(struct lp_build_sample_context *bld, @@ -1412,7 +1401,6 @@ lp_build_cube_lookup(struct lp_build_sample_context *bld, lp_build_endif(&if_ctx2); lp_build_flow_scope_end(flow_ctx2); lp_build_flow_destroy(flow_ctx2); - *face_s = face_s2; *face_t = face_t2; *face = face2; @@ -1458,13 +1446,14 @@ lp_build_sample_mipmap(struct lp_build_sample_context *bld, int chan; if (img_filter == PIPE_TEX_FILTER_NEAREST) { + /* sample the first mipmap level */ lp_build_sample_image_nearest(bld, width0_vec, height0_vec, depth0_vec, row_stride0_vec, img_stride0_vec, data_ptr0, s, t, r, colors0); if (mip_filter == PIPE_TEX_MIPFILTER_LINEAR) { - /* sample the second mipmap level, and interp */ + /* sample the second mipmap level */ lp_build_sample_image_nearest(bld, width1_vec, height1_vec, depth1_vec,
Mesa (master): gallivm: restore const qualifier
Module: Mesa Branch: master Commit: d95b40759e82b11bd4b458ec9e44eb6234da1849 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d95b40759e82b11bd4b458ec9e44eb6234da1849 Author: Brian Paul Date: Wed Jul 7 17:36:43 2010 -0600 gallivm: restore const qualifier --- src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c index 0e24ecf..1a20d74 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c @@ -1522,7 +1522,7 @@ lp_build_sample_general(struct lp_build_sample_context *bld, LLVMValueRef *colors_out) { struct lp_build_context *float_bld = &bld->float_bld; - /*const*/ unsigned mip_filter = bld->static_state->min_mip_filter; + const unsigned mip_filter = bld->static_state->min_mip_filter; const unsigned min_filter = bld->static_state->min_img_filter; const unsigned mag_filter = bld->static_state->mag_img_filter; const int dims = texture_dims(bld->static_state->target); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Add support for matrix * matrix.
Module: Mesa Branch: glsl2 Commit: 9b68b88e43c424439d425534ef280ee7a9406a1b URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9b68b88e43c424439d425534ef280ee7a9406a1b Author: Eric Anholt Date: Wed Jul 7 15:55:47 2010 -0700 ir_to_mesa: Add support for matrix * matrix. --- src/mesa/shader/ir_to_mesa.cpp | 43 +-- 1 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 21b01ed..00fa2cc 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -623,9 +623,9 @@ ir_to_mesa_visitor::visit(ir_expression *ir) case ir_binop_sub: ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); break; + case ir_binop_mul: - if (ir->operands[0]->type->is_matrix() && - !ir->operands[1]->type->is_matrix()) { + if (ir->operands[0]->type->is_matrix()) { if (ir->operands[1]->type->is_scalar()) { ir_to_mesa_dst_reg dst_column = result_dst; ir_to_mesa_src_reg src_column = op[0]; @@ -636,21 +636,32 @@ ir_to_mesa_visitor::visit(ir_expression *ir) src_column.index++; } } else { - ir_to_mesa_src_reg src_column = op[0]; + /* matrix * vec or matrix * matrix */ + int op1_col; + ir_to_mesa_dst_reg dst_column = result_dst; + ir_to_mesa_src_reg dst_column_src; ir_to_mesa_src_reg src_chan = op[1]; - assert(!ir->operands[1]->type->is_matrix() || - !"FINISHME: matrix * matrix"); -for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { - src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); - if (i == 0) { - ir_to_mesa_emit_op2(ir, OPCODE_MUL, - result_dst, src_column, src_chan); - } else { - ir_to_mesa_emit_op3(ir, OPCODE_MAD, - result_dst, src_column, src_chan, - result_src); - } - src_column.index++; + + dst_column_src = ir_to_mesa_src_reg_from_dst(result_dst); + for (op1_col = 0; op1_col < ir->operands[1]->type->matrix_columns; +op1_col++) { + ir_to_mesa_src_reg src_column = op[0]; + + for (int i = 0; i < ir->operands[0]->type->matrix_columns; i++) { + src_chan.swizzle = MAKE_SWIZZLE4(i, i, i, i); + if (i == 0) { +ir_to_mesa_emit_op2(ir, OPCODE_MUL, +dst_column, src_column, src_chan); + } else { +ir_to_mesa_emit_op3(ir, OPCODE_MAD, +dst_column, src_column, src_chan, +dst_column_src); + } + src_column.index++; + } + src_chan.index++; + dst_column.index++; + dst_column_src.index++; } } } else if (ir->operands[1]->type->is_matrix()) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_reader: Don't emit ir_function multiple times.
Module: Mesa Branch: glsl2 Commit: e024c5c6900c068634c2726d9ccfb9beac966c57 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e024c5c6900c068634c2726d9ccfb9beac966c57 Author: Kenneth Graunke Date: Wed Jul 7 15:23:27 2010 -0700 ir_reader: Don't emit ir_function multiple times. --- src/glsl/ir_reader.cpp | 16 1 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/glsl/ir_reader.cpp b/src/glsl/ir_reader.cpp index 80dbc08..0321283 100644 --- a/src/glsl/ir_reader.cpp +++ b/src/glsl/ir_reader.cpp @@ -192,6 +192,7 @@ static ir_function * read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) { void *ctx = st; + bool added = false; if (list->length() < 3) { ir_read_error(st, list, "Expected (function (signature ...) ...)"); return NULL; @@ -206,7 +207,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) ir_function *f = st->symbols->get_function(name->value()); if (f == NULL) { f = new(ctx) ir_function(name->value()); - bool added = st->symbols->add_function(f->name, f); + added = st->symbols->add_function(f->name, f); assert(added); } @@ -228,7 +229,7 @@ read_function(_mesa_glsl_parse_state *st, s_list *list, bool skip_body) read_function_sig(st, f, siglist, skip_body); } - return f; + return added ? f : NULL; } static void @@ -321,11 +322,8 @@ read_instructions(_mesa_glsl_parse_state *st, exec_list *instructions, foreach_iter(exec_list_iterator, it, list->subexpressions) { s_expression *sub = (s_expression*) it.get(); ir_instruction *ir = read_instruction(st, sub, loop_ctx); - if (ir == NULL) { -ir_read_error(st, sub, "Invalid instruction.\n"); -return; - } - instructions->push_tail(ir); + if (ir != NULL) +instructions->push_tail(ir); } } @@ -344,8 +342,10 @@ read_instruction(_mesa_glsl_parse_state *st, s_expression *expr, } s_list *list = SX_AS_LIST(expr); - if (list == NULL || list->subexpressions.is_empty()) + if (list == NULL || list->subexpressions.is_empty()) { + ir_read_error(st, expr, "Invalid instruction.\n"); return NULL; + } s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.get_head()); if (tag == NULL) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Add support for assignment of aggregates.
Module: Mesa Branch: glsl2 Commit: 7d8091f7cca0314dd66599bdce5bfcf09fe8b578 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7d8091f7cca0314dd66599bdce5bfcf09fe8b578 Author: Eric Anholt Date: Wed Jul 7 16:10:04 2010 -0700 ir_to_mesa: Add support for assignment of aggregates. --- src/mesa/shader/ir_to_mesa.cpp | 15 --- 1 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 00fa2cc..9497b17 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1268,6 +1268,7 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) { struct ir_to_mesa_dst_reg l; struct ir_to_mesa_src_reg r; + int i; assert(!ir->lhs->type->is_matrix()); assert(!ir->lhs->type->is_array()); @@ -1295,10 +1296,18 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) * an extra computing the condition. */ condition.negate = ~condition.negate; - ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, - condition, r, ir_to_mesa_src_reg_from_dst(l)); + for (i = 0; i < type_size(ir->lhs->type); i++) { +ir_to_mesa_emit_op3(ir, OPCODE_CMP, l, +condition, r, ir_to_mesa_src_reg_from_dst(l)); +l.index++; +r.index++; + } } else { - ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); + for (i = 0; i < type_size(ir->lhs->type); i++) { +ir_to_mesa_emit_op1(ir, OPCODE_MOV, l, r); +l.index++; +r.index++; + } } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Only allocate a vector per column of a matrix.
Module: Mesa Branch: glsl2 Commit: 9968f1b23c475c99139f0209c7a049ed00df01af URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9968f1b23c475c99139f0209c7a049ed00df01af Author: Eric Anholt Date: Wed Jul 7 16:16:09 2010 -0700 ir_to_mesa: Only allocate a vector per column of a matrix. --- src/mesa/shader/ir_to_mesa.cpp |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 9497b17..5cb5564 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -393,7 +393,7 @@ type_size(const struct glsl_type *type) case GLSL_TYPE_FLOAT: case GLSL_TYPE_BOOL: if (type->is_matrix()) { -return 4; /* FINISHME: Not all matrices are 4x4. */ +return type->matrix_columns; } else { /* Regardless of size of vector, it gets a vec4. This is bad * packing for things like floats, but otherwise arrays become a ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Don't assert that we can't assign matrices. It should work now.
Module: Mesa Branch: glsl2 Commit: 69676fc6a3ffbc2c99af541b954427c2e4966d68 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=69676fc6a3ffbc2c99af541b954427c2e4966d68 Author: Eric Anholt Date: Wed Jul 7 17:24:00 2010 -0700 ir_to_mesa: Don't assert that we can't assign matrices. It should work now. --- src/mesa/shader/ir_to_mesa.cpp |1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 5cb5564..e1c0fca 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1270,7 +1270,6 @@ ir_to_mesa_visitor::visit(ir_assignment *ir) struct ir_to_mesa_src_reg r; int i; - assert(!ir->lhs->type->is_matrix()); assert(!ir->lhs->type->is_array()); assert(ir->lhs->type->base_type != GLSL_TYPE_STRUCT); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Add support for adding/subtracting matrices.
Module: Mesa Branch: glsl2 Commit: b4d0c0e0ee983ee614b047799c3e01221a353c98 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4d0c0e0ee983ee614b047799c3e01221a353c98 Author: Eric Anholt Date: Wed Jul 7 17:08:58 2010 -0700 ir_to_mesa: Add support for adding/subtracting matrices. This isn't really tested, but didn't break normal vector add/sub. --- src/mesa/shader/ir_to_mesa.cpp | 42 +-- 1 files changed, 39 insertions(+), 3 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index e1c0fca..b42ac84 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -178,6 +178,13 @@ public: ir_to_mesa_src_reg src0, ir_to_mesa_src_reg src1); + void ir_to_mesa_emit_addsub(ir_expression *ir, + enum prog_opcode opcode, + struct ir_to_mesa_src_reg result_src, + struct ir_to_mesa_dst_reg result_dst, + struct ir_to_mesa_src_reg op0, + struct ir_to_mesa_src_reg op1); + int *sampler_map; int sampler_map_size; @@ -531,6 +538,32 @@ ir_to_mesa_visitor::visit(ir_function *ir) } void +ir_to_mesa_visitor::ir_to_mesa_emit_addsub(ir_expression *ir, + enum prog_opcode opcode, + struct ir_to_mesa_src_reg result_src, + struct ir_to_mesa_dst_reg result_dst, + struct ir_to_mesa_src_reg op0, + struct ir_to_mesa_src_reg op1) +{ + ir_to_mesa_dst_reg dst_column = result_dst; + int matrix_columns; + + if (ir->operands[0]->type->is_matrix()) + matrix_columns = ir->operands[0]->type->matrix_columns; + else + matrix_columns = ir->operands[1]->type->matrix_columns; + + for (int i = 0; i < matrix_columns; i++) { + ir_to_mesa_emit_op2(ir, opcode, dst_column, op0, op1); + dst_column.index++; + if (ir->operands[0]->type->is_matrix()) +op0.index++; + if (ir->operands[1]->type->is_matrix()) +op1.index++; + } +} + +void ir_to_mesa_visitor::visit(ir_expression *ir) { unsigned int operand; @@ -554,7 +587,8 @@ ir_to_mesa_visitor::visit(ir_expression *ir) /* Only expression implemented for matrices yet */ assert(!ir->operands[operand]->type->is_matrix() || -ir->operation == ir_binop_mul); +ir->operation == ir_binop_mul || +ir->operation == ir_binop_add); } this->result.file = PROGRAM_UNDEFINED; @@ -618,10 +652,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) break; case ir_binop_add: - ir_to_mesa_emit_op2(ir, OPCODE_ADD, result_dst, op[0], op[1]); + ir_to_mesa_emit_addsub(ir, OPCODE_ADD, +result_src, result_dst, op[0], op[1]); break; case ir_binop_sub: - ir_to_mesa_emit_op2(ir, OPCODE_SUB, result_dst, op[0], op[1]); + ir_to_mesa_emit_addsub(ir, OPCODE_SUB, +result_src, result_dst, op[0], op[1]); break; case ir_binop_mul: ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Add support for constant matrices (untested).
Module: Mesa Branch: glsl2 Commit: ffd24b0a6844871eed0c78608431e2f82d5615e1 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ffd24b0a6844871eed0c78608431e2f82d5615e1 Author: Eric Anholt Date: Wed Jul 7 17:49:05 2010 -0700 ir_to_mesa: Add support for constant matrices (untested). --- src/mesa/shader/ir_to_mesa.cpp | 35 +-- 1 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index b42ac84..727a815 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1355,8 +1355,39 @@ ir_to_mesa_visitor::visit(ir_constant *ir) GLfloat *values = stack_vals; unsigned int i; - if (ir->type->is_matrix() || ir->type->is_array()) { - assert(!"FINISHME: array/matrix constants"); + if (ir->type->is_array()) { + ir->print(); + printf("\n"); + assert(!"FINISHME: array constants"); + } + + if (ir->type->is_matrix()) { + /* Unfortunately, 4 floats is all we can get into + * _mesa_add_unnamed_constant. So, make a temp to store the + * matrix and move each constant value into it. If we get + * lucky, copy propagation will eliminate the extra moves. + */ + ir_to_mesa_src_reg mat = get_temp(glsl_type::vec4_type); + ir_to_mesa_dst_reg mat_column = ir_to_mesa_dst_reg_from_src(mat); + + for (i = 0; i < ir->type->matrix_columns; i++) { +src_reg.file = PROGRAM_CONSTANT; + +assert(ir->type->base_type == GLSL_TYPE_FLOAT); +values = &ir->value.f[i * ir->type->vector_elements]; + +src_reg.index = _mesa_add_unnamed_constant(this->prog->Parameters, + values, + ir->type->vector_elements, + &src_reg.swizzle); +src_reg.reladdr = false; +src_reg.negate = 0; +ir_to_mesa_emit_op1(ir, OPCODE_MOV, mat_column, src_reg); + +mat_column.index++; + } + + this->result = mat; } src_reg.file = PROGRAM_CONSTANT; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): ir_to_mesa: Fix the assertion on LHS array derefs to DWIM.
Module: Mesa Branch: glsl2 Commit: ea2a03f0a5b8b58ea88ecb607664ea50c9d6e96e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ea2a03f0a5b8b58ea88ecb607664ea50c9d6e96e Author: Eric Anholt Date: Wed Jul 7 17:59:50 2010 -0700 ir_to_mesa: Fix the assertion on LHS array derefs to DWIM. This allows array derefs of matrices now, which makes idr's GLSL demo happy. --- src/mesa/shader/ir_to_mesa.cpp | 17 ++--- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mesa/shader/ir_to_mesa.cpp b/src/mesa/shader/ir_to_mesa.cpp index 727a815..4496daf 100644 --- a/src/mesa/shader/ir_to_mesa.cpp +++ b/src/mesa/shader/ir_to_mesa.cpp @@ -1247,21 +1247,24 @@ static struct ir_to_mesa_dst_reg get_assignment_lhs(ir_instruction *ir, ir_to_mesa_visitor *v) { struct ir_to_mesa_dst_reg dst_reg; - ir_dereference *deref; ir_swizzle *swiz; + ir_dereference_array *deref_array = ir->as_dereference_array(); + /* This should have been handled by ir_vec_index_to_cond_assign */ + if (deref_array) { + assert(!deref_array->array->type->is_vector()); + + /* We don't handle relative addressing on the LHS yet. */ + assert(deref_array->array_index->constant_expression_value() != NULL); + } + /* Use the rvalue deref handler for the most part. We'll ignore * swizzles in it and write swizzles using writemask, though. */ ir->accept(v); dst_reg = ir_to_mesa_dst_reg_from_src(v->result); - if ((deref = ir->as_dereference())) { - ir_dereference_array *deref_array = ir->as_dereference_array(); - assert(!deref_array || deref_array->array->type->is_array()); - - ir->accept(v); - } else if ((swiz = ir->as_swizzle())) { + if ((swiz = ir->as_swizzle())) { dst_reg.writemask = 0; if (swiz->mask.num_components >= 1) dst_reg.writemask |= (1 << swiz->mask.x); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: initial support for new GL 3.0 texture formats
Module: Mesa Branch: master Commit: 6988f65e43297ae63bbce30bf882f870b370096c URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6988f65e43297ae63bbce30bf882f870b370096c Author: Brian Paul Date: Wed Jul 7 20:26:33 2010 -0600 mesa: initial support for new GL 3.0 texture formats --- src/mesa/main/extensions.c |6 ++- src/mesa/main/mtypes.h |6 ++- src/mesa/main/teximage.c | 75 src/mesa/main/version.c|3 +- 4 files changed, 85 insertions(+), 5 deletions(-) diff --git a/src/mesa/main/extensions.c b/src/mesa/main/extensions.c index 3d2de97..19a1eeb 100644 --- a/src/mesa/main/extensions.c +++ b/src/mesa/main/extensions.c @@ -46,8 +46,9 @@ static const struct { } default_extensions[] = { { OFF, "GL_ARB_blend_func_extended",F(ARB_blend_func_extended) }, { OFF, "GL_ARB_copy_buffer",F(ARB_copy_buffer) }, - { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, + { OFF, "GL_ARB_depth_buffer_float", F(ARB_depth_buffer_float) }, { OFF, "GL_ARB_depth_clamp",F(ARB_depth_clamp) }, + { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) }, { ON, "GL_ARB_draw_buffers", F(ARB_draw_buffers) }, { OFF, "GL_ARB_draw_elements_base_vertex", F(ARB_draw_elements_base_vertex) }, { OFF, "GL_ARB_draw_instanced", F(ARB_draw_instanced) }, @@ -92,6 +93,7 @@ static const struct { { OFF, "GL_ARB_texture_multisample",F(ARB_texture_multisample) }, { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)}, { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) }, + { OFF, "GL_ARB_texture_rg", F(ARB_texture_rg) }, { OFF, "GL_ARB_texture_rgb10_a2ui", F(ARB_texture_rgb10_a2ui) }, { OFF, "GL_ARB_texture_swizzle",F(EXT_texture_swizzle) }, { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) }, @@ -141,7 +143,6 @@ static const struct { { OFF, "GL_EXT_secondary_color",F(EXT_secondary_color) }, { ON, "GL_EXT_separate_specular_color",F(EXT_separate_specular_color) }, { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) }, - { OFF, "GL_EXT_shared_exponent",F(EXT_shared_exponent) }, { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) }, { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) }, { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) }, @@ -162,6 +163,7 @@ static const struct { { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) }, { ON, "GL_EXT_texture_object", F(EXT_texture_object) }, { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) }, + { OFF, "GL_EXT_texture_shared_exponent",F(EXT_texture_shared_exponent) }, { OFF, "GL_EXT_texture_sRGB", F(EXT_texture_sRGB) }, { OFF, "GL_EXT_texture_swizzle",F(EXT_texture_swizzle) }, { OFF, "GL_EXT_timer_query",F(EXT_timer_query) }, diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 0aeb130..a3f89f2 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -2606,8 +2606,9 @@ struct gl_extensions GLboolean dummy; /* don't remove this! */ GLboolean ARB_blend_func_extended; GLboolean ARB_copy_buffer; - GLboolean ARB_depth_texture; + GLboolean ARB_depth_buffer_float; GLboolean ARB_depth_clamp; + GLboolean ARB_depth_texture; GLboolean ARB_draw_buffers; GLboolean ARB_draw_elements_base_vertex; GLboolean ARB_draw_instanced; @@ -2647,6 +2648,7 @@ struct gl_extensions GLboolean ARB_texture_mirrored_repeat; GLboolean ARB_texture_multisample; GLboolean ARB_texture_non_power_of_two; + GLboolean ARB_texture_rg; GLboolean ARB_texture_rgb10_a2ui; GLboolean ARB_timer_query; GLboolean ARB_transform_feedback2; @@ -2694,7 +2696,6 @@ struct gl_extensions GLboolean EXT_shadow_funcs; GLboolean EXT_secondary_color; GLboolean EXT_separate_specular_color; - GLboolean EXT_shared_exponent; GLboolean EXT_shared_texture_palette; GLboolean EXT_stencil_wrap; GLboolean EXT_stencil_two_side; @@ -2712,6 +2713,7 @@ struct gl_extensions GLboolean EXT_texture_integer; GLboolean EXT_texture_lod_bias; GLboolean EXT_texture_mirror_clamp; + GLboolean EXT_texture_shared_exponent; GLboolean EXT_texture_sRGB; GLboolean EXT_texture_swizzle; GLboolean EXT_transform_feedback; diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index f307322..50890a3 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -402,6 +402,81 @@ _mesa_base_tex_format( GLcontext *ctx, GLint internalFormat ) } } + if (ctx->Extensions.ARB_texture_rg) { + switch (internalFormat) { + case GL_R8: + case GL_R16: + case
Mesa (master): gs: inject const int gl_VerticesIn at link time
Module: Mesa Branch: master Commit: 7c42390453e611367cf1ba11446692ec04e0abfb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7c42390453e611367cf1ba11446692ec04e0abfb Author: Zack Rusin Date: Wed Jul 7 00:54:33 2010 -0400 gs: inject const int gl_VerticesIn at link time --- src/mesa/main/mtypes.h | 22 ++--- src/mesa/slang/library/slang_geometry_builtin.gc |1 - src/mesa/slang/slang_builtin.c |1 - src/mesa/slang/slang_codegen.c |5 +++ src/mesa/slang/slang_link.c | 37 +++-- src/mesa/state_tracker/st_program.c | 11 +- 6 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index a3f89f2..cbb9eb8 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -252,17 +252,16 @@ typedef enum */ typedef enum { - GEOM_ATTRIB_VERTICES = 0, /*gl_VerticesIn*/ - GEOM_ATTRIB_POSITION = 1, - GEOM_ATTRIB_COLOR0 = 2, - GEOM_ATTRIB_COLOR1 = 3, - GEOM_ATTRIB_SECONDARY_COLOR0 = 4, - GEOM_ATTRIB_SECONDARY_COLOR1 = 5, - GEOM_ATTRIB_FOG_FRAG_COORD = 6, - GEOM_ATTRIB_POINT_SIZE = 7, - GEOM_ATTRIB_CLIP_VERTEX = 8, - GEOM_ATTRIB_PRIMITIVE_ID = 9, - GEOM_ATTRIB_TEX_COORD = 10, + GEOM_ATTRIB_POSITION = 0, + GEOM_ATTRIB_COLOR0 = 1, + GEOM_ATTRIB_COLOR1 = 2, + GEOM_ATTRIB_SECONDARY_COLOR0 = 3, + GEOM_ATTRIB_SECONDARY_COLOR1 = 4, + GEOM_ATTRIB_FOG_FRAG_COORD = 5, + GEOM_ATTRIB_POINT_SIZE = 6, + GEOM_ATTRIB_CLIP_VERTEX = 7, + GEOM_ATTRIB_PRIMITIVE_ID = 8, + GEOM_ATTRIB_TEX_COORD = 9, GEOM_ATTRIB_VAR0 = 16, GEOM_ATTRIB_MAX = (GEOM_ATTRIB_VAR0 + MAX_VARYING) @@ -273,7 +272,6 @@ typedef enum * These are used in bitfields in many places. */ /*...@{*/ -#define GEOM_BIT_VERTICES(1 << GEOM_ATTRIB_VERTICES) #define GEOM_BIT_COLOR0 (1 << GEOM_ATTRIB_COLOR0) #define GEOM_BIT_COLOR1 (1 << GEOM_ATTRIB_COLOR1) #define GEOM_BIT_SCOLOR0 (1 << GEOM_ATTRIB_SECONDARY_COLOR0) diff --git a/src/mesa/slang/library/slang_geometry_builtin.gc b/src/mesa/slang/library/slang_geometry_builtin.gc index c349a6a..0752491 100644 --- a/src/mesa/slang/library/slang_geometry_builtin.gc +++ b/src/mesa/slang/library/slang_geometry_builtin.gc @@ -21,7 +21,6 @@ const int _mesa_VerticesInMax = 6; -__fixed_input int gl_VerticesIn; __fixed_input int gl_PrimitiveIDIn; __fixed_output int gl_PrimitiveID; __fixed_output int gl_Layer; diff --git a/src/mesa/slang/slang_builtin.c b/src/mesa/slang/slang_builtin.c index 5c1a040..bb6fd66 100644 --- a/src/mesa/slang/slang_builtin.c +++ b/src/mesa/slang/slang_builtin.c @@ -746,7 +746,6 @@ static const struct input_info vertInputs[] = { }; static const struct input_info geomInputs[] = { - { "gl_VerticesIn", GEOM_ATTRIB_VERTICES, GL_FLOAT, SWIZZLE_NOOP }, { "gl_PrimitiveIDIn", GEOM_ATTRIB_PRIMITIVE_ID, GL_FLOAT, SWIZZLE_NOOP }, { "gl_FrontColorIn", GEOM_ATTRIB_COLOR0, GL_FLOAT_VEC4, SWIZZLE_NOOP }, { "gl_BackColorIn", GEOM_ATTRIB_COLOR1, GL_FLOAT_VEC4, SWIZZLE_NOOP }, diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c index 494901d..b2fe5b1 100644 --- a/src/mesa/slang/slang_codegen.c +++ b/src/mesa/slang/slang_codegen.c @@ -4191,6 +4191,11 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper) slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE); slang_ir_node *n; if (!var || !var->declared) { + if (A->program->Target == MESA_GEOMETRY_PROGRAM && + !strcmp((char*)name, "gl_VerticesIn") ){ + A->UnresolvedRefs = GL_TRUE; + return NULL; + } slang_info_log_error(A->log, "undefined variable '%s'", (char *) name); return NULL; } diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c index 8aa007b..c89ab8b 100644 --- a/src/mesa/slang/slang_link.c +++ b/src/mesa/slang/slang_link.c @@ -661,8 +661,8 @@ get_inputs_read_mask(GLenum target, GLuint index, GLboolean relAddr) else if (target == MESA_GEOMETRY_PROGRAM) { switch (index) { case GEOM_ATTRIB_VAR0: -mask = ((1U << (GEOM_ATTRIB_VAR0 + MAX_VARYING)) - 1) - - ((1U << GEOM_ATTRIB_VAR0) - 1); +mask = ((1ULL << (GEOM_ATTRIB_VAR0 + MAX_VARYING)) - 1) + - ((1ULL << GEOM_ATTRIB_VAR0) - 1); break; default: ; /* a non-array input attribute */ @@ -810,7 +810,25 @@ remove_extra_version_directives(GLchar *source) } } - +static int +vertices_per_prim(int prim) +{ + switch (prim) { + case GL_POINTS: + return 1; + case GL_LINES: + return 2; + case GL_TRIANGLES: + return 3; + case GL_LINES_ADJACENCY_ARB: + return 4; + case GL_TRIANGLES_ADJACENCY_ARB: + return 6; + default: + ASSERT(!"Bad primitive"); + return 3; + } +} /** * Return a new shader whose source code
Mesa (master): slang: add some comments related to geometry shaders
Module: Mesa Branch: master Commit: f11e25ee957549ab867fac4f17a5c61fd9172794 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f11e25ee957549ab867fac4f17a5c61fd9172794 Author: Zack Rusin Date: Wed Jul 7 16:41:01 2010 -0400 slang: add some comments related to geometry shaders --- src/mesa/slang/slang_codegen.c |3 +++ src/mesa/slang/slang_link.c| 12 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c index b2fe5b1..8ebe298 100644 --- a/src/mesa/slang/slang_codegen.c +++ b/src/mesa/slang/slang_codegen.c @@ -4191,6 +4191,9 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper) slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE); slang_ir_node *n; if (!var || !var->declared) { + /* Geometry shader set gl_VerticesIn at link time + * so we need to way with resolving this variable + * until then */ if (A->program->Target == MESA_GEOMETRY_PROGRAM && !strcmp((char*)name, "gl_VerticesIn") ){ A->UnresolvedRefs = GL_TRUE; diff --git a/src/mesa/slang/slang_link.c b/src/mesa/slang/slang_link.c index c89ab8b..bc2bd31 100644 --- a/src/mesa/slang/slang_link.c +++ b/src/mesa/slang/slang_link.c @@ -810,6 +810,12 @@ remove_extra_version_directives(GLchar *source) } } +/* Returns the number of vertices per geometry shader + * input primitive. + * XXX: duplicated in Gallium in u_vertices_per_prim + * method. Once Mesa core will start using Gallium + * this should be removed + */ static int vertices_per_prim(int prim) { @@ -865,6 +871,8 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) return NULL; } + /* Geometry shader will inject definition of +* const int gl_VerticesIn */ if (shaderType == GL_GEOMETRY_SHADER_ARB) { totalLen += 32; } @@ -883,6 +891,10 @@ concat_shaders(struct gl_shader_program *shProg, GLenum shaderType) len += shaderLengths[i]; } } + /* if it's geometry shader we need to inject definition +* of "const int gl_VerticesIn = X;" where X is the number +* of vertices per input primitive +*/ if (shaderType == GL_GEOMETRY_SHADER_ARB) { GLchar gs_pre[32]; GLuint num_verts = vertices_per_prim(shProg->Geom.InputType); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): slang: fix typos
Module: Mesa Branch: master Commit: 396f2cd94ffe4f11af79a1ed58fb6443fd6e124a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=396f2cd94ffe4f11af79a1ed58fb6443fd6e124a Author: Zack Rusin Date: Thu Jul 8 00:33:31 2010 -0400 slang: fix typos --- src/mesa/slang/slang_codegen.c |4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesa/slang/slang_codegen.c b/src/mesa/slang/slang_codegen.c index 8ebe298..79072cb 100644 --- a/src/mesa/slang/slang_codegen.c +++ b/src/mesa/slang/slang_codegen.c @@ -4191,8 +4191,8 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper) slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE); slang_ir_node *n; if (!var || !var->declared) { - /* Geometry shader set gl_VerticesIn at link time - * so we need to way with resolving this variable + /* Geometry shaders set gl_VerticesIn at link time + * so we need to wait with resolving this variable * until then */ if (A->program->Target == MESA_GEOMETRY_PROGRAM && !strcmp((char*)name, "gl_VerticesIn") ){ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): glsl2: Add support for gl_PointCoord in 1.20.
Module: Mesa Branch: glsl2 Commit: 152b55e74da7bf548d8846538b85960f703d6059 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=152b55e74da7bf548d8846538b85960f703d6059 Author: Eric Anholt Date: Wed Jul 7 19:45:22 2010 -0700 glsl2: Add support for gl_PointCoord in 1.20. Fixes glsl-fs-pointcoord on swrast (remains broken on 965, like master) --- src/glsl/builtin_variables.h |4 src/glsl/ir_variable.cpp |7 +++ 2 files changed, 11 insertions(+), 0 deletions(-) diff --git a/src/glsl/builtin_variables.h b/src/glsl/builtin_variables.h index 77f2fe5..9551e1a 100644 --- a/src/glsl/builtin_variables.h +++ b/src/glsl/builtin_variables.h @@ -70,6 +70,10 @@ static const builtin_variable builtin_110_deprecated_vs_variables[] = { { ir_var_out, VERT_RESULT_FOGC, "float", "gl_FogFragCoord" }, }; +static const builtin_variable builtin_120_fs_variables[] = { + { ir_var_in, FRAG_ATTRIB_PNTC, "vec2", "gl_PointCoord" }, +}; + static const builtin_variable builtin_130_vs_variables[] = { { ir_var_in, -1, "int", "gl_VertexID" }, }; diff --git a/src/glsl/ir_variable.cpp b/src/glsl/ir_variable.cpp index 9daad80..a0b66b7 100644 --- a/src/glsl/ir_variable.cpp +++ b/src/glsl/ir_variable.cpp @@ -311,6 +311,13 @@ generate_120_fs_variables(exec_list *instructions, struct _mesa_glsl_parse_state *state) { generate_110_fs_variables(instructions, state); + + for (unsigned i = 0 + ; i < Elements(builtin_120_fs_variables) + ; i++) { + add_builtin_variable(& builtin_120_fs_variables[i], + instructions, state->symbols); + } } static void ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): mesa: Fix documentation of BranchTarget for BRK.
Module: Mesa Branch: glsl2 Commit: f632a330eccb26c28a3b94216c55994e94988751 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=f632a330eccb26c28a3b94216c55994e94988751 Author: Eric Anholt Date: Wed Jul 7 21:00:32 2010 -0700 mesa: Fix documentation of BranchTarget for BRK. It was changed in 2009 and the comment wasn't updated. --- src/mesa/shader/prog_instruction.h |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h index 28c797a..c1e3a1e 100644 --- a/src/mesa/shader/prog_instruction.h +++ b/src/mesa/shader/prog_instruction.h @@ -384,7 +384,7 @@ struct prog_instruction /** * For BRA and CAL instructions, the location to jump to. * For BGNLOOP, points to ENDLOOP (and vice-versa). -* For BRK, points to BGNLOOP (which points to ENDLOOP). +* For BRK, points to ENDLOOP * For IF, points to ELSE or ENDIF. * For ELSE, points to ENDIF. */ ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (glsl2): mesa: Extend register lifetimes to the end of the largest loop required.
Module: Mesa Branch: glsl2 Commit: 25cda5039df0da6c2c65f1cac1bfc750c0c16e82 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=25cda5039df0da6c2c65f1cac1bfc750c0c16e82 Author: Eric Anholt Date: Wed Jul 7 21:28:28 2010 -0700 mesa: Extend register lifetimes to the end of the largest loop required. Previously, a register defined at main scope and used in a loop in a loop could end up getting marked as needed only from the definition outside of the loops to the end of the inner loop, and we would cleverly slot in something else in its register in the end of the outer loop. Fixes glsl-vs-loop-nested and glsl-fs-loop-nested on glsl2. This doesn't happen much on master because the original compiler does its own register allocation, so we find little we can do with linear scan register (re)allocation. --- src/mesa/shader/prog_optimize.c | 40 ++ 1 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/mesa/shader/prog_optimize.c b/src/mesa/shader/prog_optimize.c index 2941a17..bd120b8 100644 --- a/src/mesa/shader/prog_optimize.c +++ b/src/mesa/shader/prog_optimize.c @@ -728,14 +728,32 @@ sort_interval_list_by_start(struct interval_list *list) #endif } +struct loop_info +{ + GLuint Start, End; /**< Start, end instructions of loop */ +}; /** * Update the intermediate interval info for register 'index' and * instruction 'ic'. */ static void -update_interval(GLint intBegin[], GLint intEnd[], GLuint index, GLuint ic) +update_interval(GLint intBegin[], GLint intEnd[], + struct loop_info *loopStack, GLuint loopStackDepth, + GLuint index, GLuint ic) { + int i; + + /* If the register is used in a loop, extend its lifetime through the end +* of the outermost loop that doesn't contain its definition. +*/ + for (i = 0; i < loopStackDepth; i++) { + if (intBegin[index] < loopStack[i].Start) { +ic = loopStack[i].End; +break; + } + } + ASSERT(index < MAX_PROGRAM_TEMPS); if (intBegin[index] == -1) { ASSERT(intEnd[index] == -1); @@ -756,10 +774,6 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, GLint intBegin[MAX_PROGRAM_TEMPS], GLint intEnd[MAX_PROGRAM_TEMPS]) { - struct loop_info - { - GLuint Start, End; /**< Start, end instructions of loop */ - }; struct loop_info loopStack[MAX_LOOP_NESTING]; GLuint loopStackDepth = 0; GLuint i; @@ -790,24 +804,16 @@ _mesa_find_temp_intervals(const struct prog_instruction *instructions, const GLuint index = inst->SrcReg[j].Index; if (inst->SrcReg[j].RelAddr) return GL_FALSE; - update_interval(intBegin, intEnd, index, i); - if (loopStackDepth > 0) { - /* extend temp register's interval to end of loop */ - GLuint loopEnd = loopStack[loopStackDepth - 1].End; - update_interval(intBegin, intEnd, index, loopEnd); - } + update_interval(intBegin, intEnd, loopStack, loopStackDepth, + index, i); } } if (inst->DstReg.File == PROGRAM_TEMPORARY) { const GLuint index = inst->DstReg.Index; if (inst->DstReg.RelAddr) return GL_FALSE; -update_interval(intBegin, intEnd, index, i); -if (loopStackDepth > 0) { - /* extend temp register's interval to end of loop */ - GLuint loopEnd = loopStack[loopStackDepth - 1].End; - update_interval(intBegin, intEnd, index, loopEnd); -} +update_interval(intBegin, intEnd, loopStack, loopStackDepth, + index, i); } } } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit