aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/builtin_functions.cpp42
-rw-r--r--mesalib/src/glsl/ir_builder.cpp7
-rw-r--r--mesalib/src/glsl/ir_builder.h1
-rw-r--r--mesalib/src/glsl/linker.cpp15
-rw-r--r--mesalib/src/glsl/lower_packed_varyings.cpp4
-rw-r--r--mesalib/src/glsl/opt_algebraic.cpp8
-rw-r--r--mesalib/src/glsl/opt_dead_code_local.cpp26
7 files changed, 53 insertions, 50 deletions
diff --git a/mesalib/src/glsl/builtin_functions.cpp b/mesalib/src/glsl/builtin_functions.cpp
index a52077d06..0e46b53e1 100644
--- a/mesalib/src/glsl/builtin_functions.cpp
+++ b/mesalib/src/glsl/builtin_functions.cpp
@@ -194,16 +194,17 @@ shader_integer_mix(const _mesa_glsl_parse_state *state)
}
static bool
-shader_packing(const _mesa_glsl_parse_state *state)
+shader_packing_or_es3(const _mesa_glsl_parse_state *state)
{
return state->ARB_shading_language_packing_enable ||
- state->is_version(400, 0);
+ state->is_version(400, 300);
}
static bool
-shader_packing_or_es3(const _mesa_glsl_parse_state *state)
+shader_packing_or_es3_or_gpu_shader5(const _mesa_glsl_parse_state *state)
{
return state->ARB_shading_language_packing_enable ||
+ state->ARB_gpu_shader5_enable ||
state->is_version(400, 300);
}
@@ -214,6 +215,13 @@ gpu_shader5(const _mesa_glsl_parse_state *state)
}
static bool
+shader_packing_or_gpu_shader5(const _mesa_glsl_parse_state *state)
+{
+ return state->ARB_shading_language_packing_enable ||
+ gpu_shader5(state);
+}
+
+static bool
texture_array_lod(const _mesa_glsl_parse_state *state)
{
return lod_exists_in_stage(state) &&
@@ -991,16 +999,16 @@ builtin_builder::create_builtins()
_uintBitsToFloat(glsl_type::uvec4_type),
NULL);
- add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3), NULL);
- add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3), NULL);
- add_function("packUnorm4x8", _packUnorm4x8(shader_packing), NULL);
- add_function("packSnorm4x8", _packSnorm4x8(shader_packing), NULL);
- add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3), NULL);
- add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3), NULL);
- add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing), NULL);
- add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing), NULL);
- add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3), NULL);
- add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3), NULL);
+ add_function("packUnorm2x16", _packUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
+ add_function("packSnorm2x16", _packSnorm2x16(shader_packing_or_es3), NULL);
+ add_function("packUnorm4x8", _packUnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("packSnorm4x8", _packSnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("unpackUnorm2x16", _unpackUnorm2x16(shader_packing_or_es3_or_gpu_shader5), NULL);
+ add_function("unpackSnorm2x16", _unpackSnorm2x16(shader_packing_or_es3), NULL);
+ add_function("unpackUnorm4x8", _unpackUnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("unpackSnorm4x8", _unpackSnorm4x8(shader_packing_or_gpu_shader5), NULL);
+ add_function("packHalf2x16", _packHalf2x16(shader_packing_or_es3), NULL);
+ add_function("unpackHalf2x16", _unpackHalf2x16(shader_packing_or_es3), NULL);
F(length)
F(distance)
@@ -3041,7 +3049,7 @@ builtin_builder::_length(const glsl_type *type)
ir_variable *x = in_var(type, "x");
MAKE_SIG(glsl_type::float_type, always_available, 1, x);
- body.emit(ret(sqrt(dotlike(x, x))));
+ body.emit(ret(sqrt(dot(x, x))));
return sig;
}
@@ -3131,7 +3139,7 @@ builtin_builder::_faceforward(const glsl_type *type)
ir_variable *Nref = in_var(type, "Nref");
MAKE_SIG(type, always_available, 3, N, I, Nref);
- body.emit(if_tree(less(dotlike(Nref, I), imm(0.0f)),
+ body.emit(if_tree(less(dot(Nref, I), imm(0.0f)),
ret(N), ret(neg(N))));
return sig;
@@ -3145,7 +3153,7 @@ builtin_builder::_reflect(const glsl_type *type)
MAKE_SIG(type, always_available, 2, I, N);
/* I - 2 * dot(N, I) * N */
- body.emit(ret(sub(I, mul(imm(2.0f), mul(dotlike(N, I), N)))));
+ body.emit(ret(sub(I, mul(imm(2.0f), mul(dot(N, I), N)))));
return sig;
}
@@ -3159,7 +3167,7 @@ builtin_builder::_refract(const glsl_type *type)
MAKE_SIG(type, always_available, 3, I, N, eta);
ir_variable *n_dot_i = body.make_temp(glsl_type::float_type, "n_dot_i");
- body.emit(assign(n_dot_i, dotlike(N, I)));
+ body.emit(assign(n_dot_i, dot(N, I)));
/* From the GLSL 1.10 specification:
* k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I))
diff --git a/mesalib/src/glsl/ir_builder.cpp b/mesalib/src/glsl/ir_builder.cpp
index 7f41ed69e..f4a1c6efa 100644
--- a/mesalib/src/glsl/ir_builder.cpp
+++ b/mesalib/src/glsl/ir_builder.cpp
@@ -251,13 +251,8 @@ ir_expression *round_even(operand a)
return expr(ir_unop_round_even, a);
}
-ir_expression *dot(operand a, operand b)
-{
- return expr(ir_binop_dot, a, b);
-}
-
/* dot for vectors, mul for scalars */
-ir_expression *dotlike(operand a, operand b)
+ir_expression *dot(operand a, operand b)
{
assert(a.val->type == b.val->type);
diff --git a/mesalib/src/glsl/ir_builder.h b/mesalib/src/glsl/ir_builder.h
index f00e6f3b3..108b53a5e 100644
--- a/mesalib/src/glsl/ir_builder.h
+++ b/mesalib/src/glsl/ir_builder.h
@@ -139,7 +139,6 @@ ir_expression *carry(operand a, operand b);
ir_expression *borrow(operand a, operand b);
ir_expression *round_even(operand a);
ir_expression *dot(operand a, operand b);
-ir_expression *dotlike(operand a, operand b);
ir_expression *clamp(operand a, operand b, operand c);
ir_expression *saturate(operand a);
ir_expression *abs(operand a);
diff --git a/mesalib/src/glsl/linker.cpp b/mesalib/src/glsl/linker.cpp
index f6b266185..3bf278965 100644
--- a/mesalib/src/glsl/linker.cpp
+++ b/mesalib/src/glsl/linker.cpp
@@ -2303,17 +2303,10 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
}
/* Mark all generic shader inputs and outputs as unpaired. */
- if (prog->_LinkedShaders[MESA_SHADER_VERTEX] != NULL) {
- link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_VERTEX]->ir);
- }
- if (prog->_LinkedShaders[MESA_SHADER_GEOMETRY] != NULL) {
- link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_GEOMETRY]->ir);
- }
- if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] != NULL) {
- link_invalidate_variable_locations(
- prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->ir);
+ for (unsigned i = MESA_SHADER_VERTEX; i <= MESA_SHADER_FRAGMENT; i++) {
+ if (prog->_LinkedShaders[i] != NULL) {
+ link_invalidate_variable_locations(prog->_LinkedShaders[i]->ir);
+ }
}
/* FINISHME: The value of the max_attribute_index parameter is
diff --git a/mesalib/src/glsl/lower_packed_varyings.cpp b/mesalib/src/glsl/lower_packed_varyings.cpp
index c23d1801b..8c1b8850b 100644
--- a/mesalib/src/glsl/lower_packed_varyings.cpp
+++ b/mesalib/src/glsl/lower_packed_varyings.cpp
@@ -199,8 +199,8 @@ private:
/**
* Number of generic varying slots which are used by this shader. This is
- * used to allocate temporary intermediate data structures. If any any
- * varying used by this shader has a location greater than or equal to
+ * used to allocate temporary intermediate data structures. If any varying
+ * used by this shader has a location greater than or equal to
* location_base + locations_used, an assertion will fire.
*/
const unsigned locations_used;
diff --git a/mesalib/src/glsl/opt_algebraic.cpp b/mesalib/src/glsl/opt_algebraic.cpp
index 5c49a785c..8494bd9ec 100644
--- a/mesalib/src/glsl/opt_algebraic.cpp
+++ b/mesalib/src/glsl/opt_algebraic.cpp
@@ -528,6 +528,14 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
if (is_vec_two(op_const[0]))
return expr(ir_unop_exp2, ir->operands[1]);
+ if (is_vec_two(op_const[1])) {
+ ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
+ ir_var_temporary);
+ base_ir->insert_before(x);
+ base_ir->insert_before(assign(x, ir->operands[0]));
+ return mul(x, x);
+ }
+
break;
case ir_unop_rcp:
diff --git a/mesalib/src/glsl/opt_dead_code_local.cpp b/mesalib/src/glsl/opt_dead_code_local.cpp
index e7d46edbe..0c5c684a4 100644
--- a/mesalib/src/glsl/opt_dead_code_local.cpp
+++ b/mesalib/src/glsl/opt_dead_code_local.cpp
@@ -51,14 +51,14 @@ public:
assert(ir);
this->lhs = lhs;
this->ir = ir;
- this->available = ir->write_mask;
+ this->unused = ir->write_mask;
}
ir_variable *lhs;
ir_assignment *ir;
/* bitmask of xyzw channels written that haven't been used so far. */
- int available;
+ int unused;
};
class kill_for_derefs_visitor : public ir_hierarchical_visitor {
@@ -68,7 +68,7 @@ public:
this->assignments = assignments;
}
- void kill_channels(ir_variable *const var, int used)
+ void use_channels(ir_variable *const var, int used)
{
foreach_list_safe(n, this->assignments) {
assignment_entry *entry = (assignment_entry *) n;
@@ -76,14 +76,14 @@ public:
if (entry->lhs == var) {
if (var->type->is_scalar() || var->type->is_vector()) {
if (debug)
- printf("kill %s (0x%01x - 0x%01x)\n", entry->lhs->name,
- entry->available, used);
- entry->available &= ~used;
- if (!entry->available)
+ printf("used %s (0x%01x - 0x%01x)\n", entry->lhs->name,
+ entry->unused, used & 0xf);
+ entry->unused &= ~used;
+ if (!entry->unused)
entry->remove();
} else {
if (debug)
- printf("kill %s\n", entry->lhs->name);
+ printf("used %s\n", entry->lhs->name);
entry->remove();
}
}
@@ -92,7 +92,7 @@ public:
virtual ir_visitor_status visit(ir_dereference_variable *ir)
{
- kill_channels(ir->var, ~0);
+ use_channels(ir->var, ~0);
return visit_continue;
}
@@ -109,7 +109,7 @@ public:
used |= 1 << ir->mask.z;
used |= 1 << ir->mask.w;
- kill_channels(deref->var, used);
+ use_channels(deref->var, used);
return visit_continue_with_parent;
}
@@ -202,7 +202,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
if (entry->lhs != var)
continue;
- int remove = entry->available & ir->write_mask;
+ int remove = entry->unused & ir->write_mask;
if (debug) {
printf("%s 0x%01x - 0x%01x = 0x%01x\n",
var->name,
@@ -219,7 +219,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
}
entry->ir->write_mask &= ~remove;
- entry->available &= ~remove;
+ entry->unused &= ~remove;
if (entry->ir->write_mask == 0) {
/* Delete the dead assignment. */
entry->ir->remove();
@@ -283,7 +283,7 @@ process_assignment(void *ctx, ir_assignment *ir, exec_list *assignments)
foreach_list(n, assignments) {
assignment_entry *entry = (assignment_entry *) n;
- printf(" %s (0x%01x)\n", entry->lhs->name, entry->available);
+ printf(" %s (0x%01x)\n", entry->lhs->name, entry->unused);
}
}