2011-08-11 20:58:21 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2011 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-08 22:44:04 +02:00
|
|
|
* \file lower_distance.cpp
|
2011-08-11 20:58:21 -07:00
|
|
|
*
|
|
|
|
|
* This pass accounts for the difference between the way
|
2016-05-14 11:37:48 +10:00
|
|
|
* gl_ClipDistance is declared in standard GLSL (as an array of
|
|
|
|
|
* floats), and the way it is frequently implemented in hardware (as
|
|
|
|
|
* a pair of vec4s, with four clip distances packed into each).
|
2011-08-11 20:58:21 -07:00
|
|
|
*
|
2016-05-14 11:37:48 +10:00
|
|
|
* The declaration of gl_ClipDistance is replaced with a declaration
|
|
|
|
|
* of gl_ClipDistanceMESA, and any references to gl_ClipDistance are
|
|
|
|
|
* translated to refer to gl_ClipDistanceMESA with the appropriate
|
|
|
|
|
* swizzling of array indices. For instance:
|
2011-08-11 20:58:21 -07:00
|
|
|
*
|
|
|
|
|
* gl_ClipDistance[i]
|
|
|
|
|
*
|
|
|
|
|
* is translated into:
|
|
|
|
|
*
|
|
|
|
|
* gl_ClipDistanceMESA[i>>2][i&3]
|
|
|
|
|
*
|
2016-05-14 11:37:48 +10:00
|
|
|
* Since some hardware may not internally represent gl_ClipDistance as a pair
|
|
|
|
|
* of vec4's, this lowering pass is optional. To enable it, set the
|
|
|
|
|
* LowerCombinedClipCullDistance flag in gl_shader_compiler_options to true.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
#include "main/macros.h"
|
2012-12-04 11:11:02 -08:00
|
|
|
#include "glsl_symbol_table.h"
|
2013-05-08 10:48:55 -07:00
|
|
|
#include "ir_rvalue_visitor.h"
|
2011-08-11 20:58:21 -07:00
|
|
|
#include "ir.h"
|
2013-03-22 17:42:38 -07:00
|
|
|
#include "program/prog_instruction.h" /* For WRITEMASK_* */
|
2011-08-11 20:58:21 -07:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
#define GLSL_CLIP_VAR_NAME "gl_ClipDistanceMESA"
|
|
|
|
|
|
2013-09-20 11:03:44 -07:00
|
|
|
namespace {
|
|
|
|
|
|
2016-05-08 22:44:04 +02:00
|
|
|
class lower_distance_visitor : public ir_rvalue_visitor {
|
2011-08-11 20:58:21 -07:00
|
|
|
public:
|
2016-05-16 08:47:32 +10:00
|
|
|
explicit lower_distance_visitor(gl_shader_stage shader_stage,
|
|
|
|
|
const char *in_name, int total_size,
|
|
|
|
|
int offset)
|
2016-05-08 22:44:04 +02:00
|
|
|
: progress(false), old_distance_out_var(NULL),
|
|
|
|
|
old_distance_in_var(NULL), new_distance_out_var(NULL),
|
2016-05-16 08:47:32 +10:00
|
|
|
new_distance_in_var(NULL), shader_stage(shader_stage),
|
|
|
|
|
in_name(in_name), total_size(total_size), offset(offset)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
explicit lower_distance_visitor(gl_shader_stage shader_stage,
|
|
|
|
|
const char *in_name,
|
|
|
|
|
const lower_distance_visitor *orig,
|
|
|
|
|
int offset)
|
|
|
|
|
: progress(false),
|
|
|
|
|
old_distance_out_var(NULL),
|
|
|
|
|
old_distance_in_var(NULL),
|
|
|
|
|
new_distance_out_var(orig->new_distance_out_var),
|
|
|
|
|
new_distance_in_var(orig->new_distance_in_var),
|
|
|
|
|
shader_stage(shader_stage),
|
|
|
|
|
in_name(in_name),
|
|
|
|
|
total_size(orig->total_size),
|
|
|
|
|
offset(offset)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ir_visitor_status visit(ir_variable *);
|
|
|
|
|
void create_indices(ir_rvalue*, ir_rvalue *&, ir_rvalue *&);
|
2016-05-08 22:44:04 +02:00
|
|
|
bool is_distance_vec8(ir_rvalue *ir);
|
|
|
|
|
ir_rvalue *lower_distance_vec8(ir_rvalue *ir);
|
2011-08-11 20:58:21 -07:00
|
|
|
virtual ir_visitor_status visit_leave(ir_assignment *);
|
|
|
|
|
void visit_new_assignment(ir_assignment *ir);
|
|
|
|
|
virtual ir_visitor_status visit_leave(ir_call *);
|
|
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
virtual void handle_rvalue(ir_rvalue **rvalue);
|
|
|
|
|
|
2013-03-22 17:42:38 -07:00
|
|
|
void fix_lhs(ir_assignment *);
|
|
|
|
|
|
2011-08-11 20:58:21 -07:00
|
|
|
bool progress;
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-14 11:37:48 +10:00
|
|
|
* Pointer to the declaration of gl_ClipDistance, if found.
|
2013-02-15 09:30:51 -06:00
|
|
|
*
|
|
|
|
|
* Note:
|
|
|
|
|
*
|
2014-03-20 22:33:05 +01:00
|
|
|
* - the in_var is for geometry and both tessellation shader inputs only.
|
2013-02-15 09:30:51 -06:00
|
|
|
*
|
2014-03-20 22:33:05 +01:00
|
|
|
* - since gl_ClipDistance is available in tessellation control,
|
|
|
|
|
* tessellation evaluation and geometry shaders as both an input
|
2016-05-08 22:44:04 +02:00
|
|
|
* and an output, it's possible for both old_distance_out_var
|
|
|
|
|
* and old_distance_in_var to be non-null.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
2016-05-08 22:44:04 +02:00
|
|
|
ir_variable *old_distance_out_var;
|
|
|
|
|
ir_variable *old_distance_in_var;
|
2011-08-11 20:58:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-05-14 11:37:48 +10:00
|
|
|
* Pointer to the newly-created gl_ClipDistanceMESA variable.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
2016-05-08 22:44:04 +02:00
|
|
|
ir_variable *new_distance_out_var;
|
|
|
|
|
ir_variable *new_distance_in_var;
|
2013-02-15 09:30:51 -06:00
|
|
|
|
|
|
|
|
/**
|
2014-01-07 11:19:22 -08:00
|
|
|
* Type of shader we are compiling (e.g. MESA_SHADER_VERTEX)
|
2013-02-15 09:30:51 -06:00
|
|
|
*/
|
2014-01-07 11:19:22 -08:00
|
|
|
const gl_shader_stage shader_stage;
|
2016-05-16 08:47:32 +10:00
|
|
|
const char *in_name;
|
|
|
|
|
int total_size;
|
|
|
|
|
int offset;
|
2011-08-11 20:58:21 -07:00
|
|
|
};
|
|
|
|
|
|
2013-09-20 11:03:44 -07:00
|
|
|
} /* anonymous namespace */
|
2011-08-11 20:58:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-05-16 08:47:32 +10:00
|
|
|
* Replace any declaration of 'in_name' as an array of floats with a
|
2016-05-14 11:37:48 +10:00
|
|
|
* declaration of gl_ClipDistanceMESA as an array of vec4's.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
ir_visitor_status
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::visit(ir_variable *ir)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
2014-03-20 22:33:05 +01:00
|
|
|
ir_variable **old_var;
|
|
|
|
|
ir_variable **new_var;
|
|
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
if (!ir->name || strcmp(ir->name, in_name) != 0)
|
2011-08-11 20:58:21 -07:00
|
|
|
return visit_continue;
|
2013-02-15 09:30:51 -06:00
|
|
|
assert (ir->type->is_array());
|
|
|
|
|
|
2014-03-20 22:33:05 +01:00
|
|
|
if (ir->data.mode == ir_var_shader_out) {
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_out_var)
|
2014-03-20 22:33:05 +01:00
|
|
|
return visit_continue;
|
2016-05-08 22:44:04 +02:00
|
|
|
old_var = &old_distance_out_var;
|
|
|
|
|
new_var = &new_distance_out_var;
|
2014-03-20 22:33:05 +01:00
|
|
|
} else if (ir->data.mode == ir_var_shader_in) {
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_in_var)
|
2013-02-15 09:30:51 -06:00
|
|
|
return visit_continue;
|
2016-05-08 22:44:04 +02:00
|
|
|
old_var = &old_distance_in_var;
|
|
|
|
|
new_var = &new_distance_in_var;
|
2014-03-20 22:33:05 +01:00
|
|
|
} else {
|
|
|
|
|
unreachable("not reached");
|
|
|
|
|
}
|
2011-08-11 20:58:21 -07:00
|
|
|
|
2014-03-20 22:33:05 +01:00
|
|
|
this->progress = true;
|
|
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
*old_var = ir;
|
2014-03-20 22:33:05 +01:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
if (!(*new_var)) {
|
|
|
|
|
unsigned new_size = (total_size + 3) / 4;
|
2016-05-14 11:37:48 +10:00
|
|
|
|
|
|
|
|
/* Clone the old var so that we inherit all of its properties */
|
|
|
|
|
*new_var = ir->clone(ralloc_parent(ir), NULL);
|
2016-05-16 08:47:32 +10:00
|
|
|
(*new_var)->name = ralloc_strdup(*new_var, GLSL_CLIP_VAR_NAME);
|
|
|
|
|
(*new_var)->data.max_array_access = new_size - 1;
|
2016-05-25 06:03:24 +10:00
|
|
|
(*new_var)->data.location = VARYING_SLOT_CLIP_DIST0;
|
2016-05-14 11:37:48 +10:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
if (!ir->type->fields.array->is_array()) {
|
|
|
|
|
/* gl_ClipDistance (used for vertex, tessellation evaluation and
|
|
|
|
|
* geometry output, and fragment input).
|
|
|
|
|
*/
|
|
|
|
|
assert((ir->data.mode == ir_var_shader_in &&
|
|
|
|
|
this->shader_stage == MESA_SHADER_FRAGMENT) ||
|
|
|
|
|
(ir->data.mode == ir_var_shader_out &&
|
|
|
|
|
(this->shader_stage == MESA_SHADER_VERTEX ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_TESS_EVAL ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_GEOMETRY)));
|
|
|
|
|
|
|
|
|
|
assert (ir->type->fields.array == glsl_type::float_type);
|
|
|
|
|
|
|
|
|
|
/* And change the properties that we need to change */
|
|
|
|
|
(*new_var)->type = glsl_type::get_array_instance(glsl_type::vec4_type,
|
|
|
|
|
new_size);
|
|
|
|
|
} else {
|
|
|
|
|
/* 2D gl_ClipDistance (used for tessellation control, tessellation
|
|
|
|
|
* evaluation and geometry input, and tessellation control output).
|
|
|
|
|
*/
|
|
|
|
|
assert((ir->data.mode == ir_var_shader_in &&
|
|
|
|
|
(this->shader_stage == MESA_SHADER_GEOMETRY ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_TESS_EVAL)) ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_TESS_CTRL);
|
|
|
|
|
|
|
|
|
|
assert (ir->type->fields.array->fields.array == glsl_type::float_type);
|
|
|
|
|
|
|
|
|
|
/* And change the properties that we need to change */
|
|
|
|
|
(*new_var)->type = glsl_type::get_array_instance(
|
|
|
|
|
glsl_type::get_array_instance(glsl_type::vec4_type,
|
|
|
|
|
new_size),
|
|
|
|
|
ir->type->array_size());
|
|
|
|
|
}
|
2016-05-14 11:37:48 +10:00
|
|
|
ir->replace_with(*new_var);
|
2013-02-15 09:30:51 -06:00
|
|
|
} else {
|
2016-05-16 08:47:32 +10:00
|
|
|
ir->remove();
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
2014-03-20 22:33:05 +01:00
|
|
|
|
2011-08-11 20:58:21 -07:00
|
|
|
return visit_continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-14 11:37:48 +10:00
|
|
|
* Create the necessary GLSL rvalues to index into gl_ClipDistanceMESA based
|
2011-08-11 20:58:21 -07:00
|
|
|
* on the rvalue previously used to index into gl_ClipDistance.
|
|
|
|
|
*
|
2016-05-14 11:37:48 +10:00
|
|
|
* \param array_index Selects one of the vec4's in gl_ClipDistanceMESA
|
2011-08-11 20:58:21 -07:00
|
|
|
* \param swizzle_index Selects a component within the vec4 selected by
|
|
|
|
|
* array_index.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::create_indices(ir_rvalue *old_index,
|
2011-08-11 20:58:21 -07:00
|
|
|
ir_rvalue *&array_index,
|
|
|
|
|
ir_rvalue *&swizzle_index)
|
|
|
|
|
{
|
|
|
|
|
void *ctx = ralloc_parent(old_index);
|
|
|
|
|
|
|
|
|
|
/* Make sure old_index is a signed int so that the bitwise "shift" and
|
|
|
|
|
* "and" operations below type check properly.
|
|
|
|
|
*/
|
|
|
|
|
if (old_index->type != glsl_type::int_type) {
|
|
|
|
|
assert (old_index->type == glsl_type::uint_type);
|
|
|
|
|
old_index = new(ctx) ir_expression(ir_unop_u2i, old_index);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ir_constant *old_index_constant = old_index->constant_expression_value();
|
|
|
|
|
if (old_index_constant) {
|
2016-05-14 11:37:48 +10:00
|
|
|
/* gl_ClipDistance is being accessed via a constant index. Don't bother
|
|
|
|
|
* creating expressions to calculate the lowered indices. Just create
|
|
|
|
|
* constants.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
2016-05-16 08:47:32 +10:00
|
|
|
int const_val = old_index_constant->get_int_component(0) + offset;
|
2016-05-14 11:37:48 +10:00
|
|
|
array_index = new(ctx) ir_constant(const_val / 4);
|
|
|
|
|
swizzle_index = new(ctx) ir_constant(const_val % 4);
|
2011-08-11 20:58:21 -07:00
|
|
|
} else {
|
|
|
|
|
/* Create a variable to hold the value of old_index (so that we
|
|
|
|
|
* don't compute it twice).
|
|
|
|
|
*/
|
|
|
|
|
ir_variable *old_index_var = new(ctx) ir_variable(
|
2016-05-08 22:44:04 +02:00
|
|
|
glsl_type::int_type, "distance_index", ir_var_temporary);
|
2011-08-11 20:58:21 -07:00
|
|
|
this->base_ir->insert_before(old_index_var);
|
|
|
|
|
this->base_ir->insert_before(new(ctx) ir_assignment(
|
|
|
|
|
new(ctx) ir_dereference_variable(old_index_var), old_index));
|
|
|
|
|
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Create the expression distance_index / 4. Do this as a bit
|
|
|
|
|
* shift because that's likely to be more efficient.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
array_index = new(ctx) ir_expression(
|
2016-05-16 08:47:32 +10:00
|
|
|
ir_binop_rshift,
|
|
|
|
|
new(ctx) ir_expression(ir_binop_add,
|
|
|
|
|
new(ctx) ir_dereference_variable(old_index_var),
|
|
|
|
|
new(ctx) ir_constant(offset)),
|
2011-08-11 20:58:21 -07:00
|
|
|
new(ctx) ir_constant(2));
|
|
|
|
|
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Create the expression distance_index % 4. Do this as a bitwise
|
|
|
|
|
* AND because that's likely to be more efficient.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
swizzle_index = new(ctx) ir_expression(
|
2016-05-16 08:47:32 +10:00
|
|
|
ir_binop_bit_and,
|
|
|
|
|
new(ctx) ir_expression(ir_binop_add,
|
|
|
|
|
new(ctx) ir_dereference_variable(old_index_var),
|
|
|
|
|
new(ctx) ir_constant(offset)),
|
2011-08-11 20:58:21 -07:00
|
|
|
new(ctx) ir_constant(3));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-15 09:30:51 -06:00
|
|
|
/**
|
|
|
|
|
* Determine whether the given rvalue describes an array of 8 floats that
|
|
|
|
|
* needs to be lowered to an array of 2 vec4's; that is, determine whether it
|
|
|
|
|
* matches one of the following patterns:
|
|
|
|
|
*
|
|
|
|
|
* - gl_ClipDistance (if gl_ClipDistance is 1D)
|
|
|
|
|
* - gl_ClipDistance[i] (if gl_ClipDistance is 2D)
|
|
|
|
|
*/
|
|
|
|
|
bool
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::is_distance_vec8(ir_rvalue *ir)
|
2013-02-15 09:30:51 -06:00
|
|
|
{
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Note that geometry shaders contain gl_ClipDistance both as an input
|
|
|
|
|
* (which is a 2D array) and an output (which is a 1D array), so it's
|
|
|
|
|
* possible for both this->old_distance_out_var and
|
2016-05-08 22:44:04 +02:00
|
|
|
* this->old_distance_in_var to be non-NULL in the same shader.
|
2013-02-15 09:30:51 -06:00
|
|
|
*/
|
|
|
|
|
|
2014-03-20 22:33:05 +01:00
|
|
|
if (!ir->type->is_array())
|
|
|
|
|
return false;
|
|
|
|
|
if (ir->type->fields.array != glsl_type::float_type)
|
|
|
|
|
return false;
|
|
|
|
|
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_out_var) {
|
|
|
|
|
if (ir->variable_referenced() == this->old_distance_out_var)
|
2013-02-15 09:30:51 -06:00
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_in_var) {
|
2014-03-20 22:33:05 +01:00
|
|
|
assert(this->shader_stage == MESA_SHADER_TESS_CTRL ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_TESS_EVAL ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_GEOMETRY ||
|
|
|
|
|
this->shader_stage == MESA_SHADER_FRAGMENT);
|
2013-02-15 09:30:51 -06:00
|
|
|
|
2016-05-08 22:44:04 +02:00
|
|
|
if (ir->variable_referenced() == this->old_distance_in_var)
|
2014-03-20 22:33:05 +01:00
|
|
|
return true;
|
2013-02-15 09:30:51 -06:00
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-08 22:44:04 +02:00
|
|
|
* If the given ir satisfies is_distance_vec8(), return new ir
|
2013-02-15 09:30:51 -06:00
|
|
|
* representing its lowered equivalent. That is, map:
|
|
|
|
|
*
|
|
|
|
|
* - gl_ClipDistance => gl_ClipDistanceMESA (if gl_ClipDistance is 1D)
|
|
|
|
|
* - gl_ClipDistance[i] => gl_ClipDistanceMESA[i] (if gl_ClipDistance is 2D)
|
|
|
|
|
*
|
|
|
|
|
* Otherwise return NULL.
|
|
|
|
|
*/
|
|
|
|
|
ir_rvalue *
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::lower_distance_vec8(ir_rvalue *ir)
|
2013-02-15 09:30:51 -06:00
|
|
|
{
|
2014-03-20 22:33:05 +01:00
|
|
|
if (!ir->type->is_array())
|
|
|
|
|
return NULL;
|
|
|
|
|
if (ir->type->fields.array != glsl_type::float_type)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
ir_variable **new_var = NULL;
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_out_var) {
|
|
|
|
|
if (ir->variable_referenced() == this->old_distance_out_var)
|
|
|
|
|
new_var = &this->new_distance_out_var;
|
2014-03-20 22:33:05 +01:00
|
|
|
}
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->old_distance_in_var) {
|
|
|
|
|
if (ir->variable_referenced() == this->old_distance_in_var)
|
|
|
|
|
new_var = &this->new_distance_in_var;
|
2013-02-15 09:30:51 -06:00
|
|
|
}
|
2014-03-20 22:33:05 +01:00
|
|
|
if (new_var == NULL)
|
|
|
|
|
return NULL;
|
2013-02-15 09:30:51 -06:00
|
|
|
|
2014-03-20 22:33:05 +01:00
|
|
|
if (ir->as_dereference_variable()) {
|
|
|
|
|
return new(ralloc_parent(ir)) ir_dereference_variable(*new_var);
|
|
|
|
|
} else {
|
2013-02-15 09:30:51 -06:00
|
|
|
ir_dereference_array *array_ref = ir->as_dereference_array();
|
2014-03-20 22:33:05 +01:00
|
|
|
assert(array_ref);
|
|
|
|
|
assert(array_ref->array->as_dereference_variable());
|
|
|
|
|
|
|
|
|
|
return new(ralloc_parent(ir))
|
|
|
|
|
ir_dereference_array(*new_var, array_ref->array_index);
|
2013-02-15 09:30:51 -06:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
void
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::handle_rvalue(ir_rvalue **rv)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
2013-02-15 09:30:51 -06:00
|
|
|
if (*rv == NULL)
|
2013-05-08 10:48:55 -07:00
|
|
|
return;
|
2011-08-11 20:58:21 -07:00
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
ir_dereference_array *const array_deref = (*rv)->as_dereference_array();
|
|
|
|
|
if (array_deref == NULL)
|
|
|
|
|
return;
|
|
|
|
|
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Replace any expression that indexes one of the floats in gl_ClipDistance
|
|
|
|
|
* with an expression that indexes into one of the vec4's in
|
|
|
|
|
* gl_ClipDistanceMESA and accesses the appropriate component.
|
2013-05-08 10:48:55 -07:00
|
|
|
*/
|
2013-02-15 09:30:51 -06:00
|
|
|
ir_rvalue *lowered_vec8 =
|
2016-05-08 22:44:04 +02:00
|
|
|
this->lower_distance_vec8(array_deref->array);
|
2013-02-15 09:30:51 -06:00
|
|
|
if (lowered_vec8 != NULL) {
|
2011-08-11 20:58:21 -07:00
|
|
|
this->progress = true;
|
|
|
|
|
ir_rvalue *array_index;
|
|
|
|
|
ir_rvalue *swizzle_index;
|
2013-05-08 10:48:55 -07:00
|
|
|
this->create_indices(array_deref->array_index, array_index, swizzle_index);
|
|
|
|
|
void *mem_ctx = ralloc_parent(array_deref);
|
2013-03-22 17:42:38 -07:00
|
|
|
|
2013-02-15 09:30:51 -06:00
|
|
|
ir_dereference_array *const new_array_deref =
|
|
|
|
|
new(mem_ctx) ir_dereference_array(lowered_vec8, array_index);
|
2013-03-22 17:42:38 -07:00
|
|
|
|
|
|
|
|
ir_expression *const expr =
|
|
|
|
|
new(mem_ctx) ir_expression(ir_binop_vector_extract,
|
2013-02-15 09:30:51 -06:00
|
|
|
new_array_deref,
|
2013-03-22 17:42:38 -07:00
|
|
|
swizzle_index);
|
|
|
|
|
|
|
|
|
|
*rv = expr;
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-03-22 17:42:38 -07:00
|
|
|
void
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::fix_lhs(ir_assignment *ir)
|
2013-03-22 17:42:38 -07:00
|
|
|
{
|
|
|
|
|
if (ir->lhs->ir_type == ir_type_expression) {
|
|
|
|
|
void *mem_ctx = ralloc_parent(ir);
|
|
|
|
|
ir_expression *const expr = (ir_expression *) ir->lhs;
|
|
|
|
|
|
|
|
|
|
/* The expression must be of the form:
|
|
|
|
|
*
|
|
|
|
|
* (vector_extract gl_ClipDistanceMESA[i], j).
|
|
|
|
|
*/
|
|
|
|
|
assert(expr->operation == ir_binop_vector_extract);
|
|
|
|
|
assert(expr->operands[0]->ir_type == ir_type_dereference_array);
|
|
|
|
|
assert(expr->operands[0]->type == glsl_type::vec4_type);
|
|
|
|
|
|
|
|
|
|
ir_dereference *const new_lhs = (ir_dereference *) expr->operands[0];
|
|
|
|
|
ir->rhs = new(mem_ctx) ir_expression(ir_triop_vector_insert,
|
2016-05-16 08:47:32 +10:00
|
|
|
glsl_type::vec4_type,
|
|
|
|
|
new_lhs->clone(mem_ctx, NULL),
|
|
|
|
|
ir->rhs,
|
|
|
|
|
expr->operands[1]);
|
2013-03-22 17:42:38 -07:00
|
|
|
ir->set_lhs(new_lhs);
|
|
|
|
|
ir->write_mask = WRITEMASK_XYZW;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-08-11 20:58:21 -07:00
|
|
|
|
|
|
|
|
/**
|
2016-05-14 11:37:48 +10:00
|
|
|
* Replace any assignment having the 1D gl_ClipDistance (undereferenced) as
|
2013-02-15 09:30:51 -06:00
|
|
|
* its LHS or RHS with a sequence of assignments, one for each component of
|
|
|
|
|
* the array. Each of these assignments is lowered to refer to
|
2016-05-14 11:37:48 +10:00
|
|
|
* gl_ClipDistanceMESA as appropriate.
|
2013-02-15 09:30:51 -06:00
|
|
|
*
|
2016-05-14 11:37:48 +10:00
|
|
|
* We need to do a similar replacement for 2D gl_ClipDistance, however since
|
2013-02-15 09:30:51 -06:00
|
|
|
* it's an input, the only case we need to address is where a 1D slice of it
|
|
|
|
|
* is the entire RHS of an assignment, e.g.:
|
|
|
|
|
*
|
|
|
|
|
* foo = gl_in[i].gl_ClipDistance
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
ir_visitor_status
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::visit_leave(ir_assignment *ir)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
glsl: Fix lowering of direct assignment in lower_clip_distance.
In commit 065da16 (glsl: Convert lower_clip_distance_visitor to be an
ir_rvalue_visitor), we failed to notice that since
lower_clip_distance_visitor overrides visit_leave(ir_assignment *),
ir_rvalue_visitor::visit_leave(ir_assignment *) wasn't getting called.
As a result, clip distance dereferences appearing directly on the
right hand side of an assignment (not in a subexpression) weren't
getting properly lowered. This caused an ir_dereference_variable node
to be left in the IR that referred to the old gl_ClipDistance
variable. However, since the lowering pass replaces gl_ClipDistance
with gl_ClipDistanceMESA, this turned into a dangling pointer when the
IR got reparented.
Prior to the introduction of geometry shaders, this bug was unlikely
to arise, because (a) reading from gl_ClipDistance[i] in the fragment
shader was rare, and (b) when it happened, it was likely that it would
either appear in a subexpression, or be hoisted into a subexpression
by tree grafting.
However, in a geometry shader, we're likely to see a statement like
this, which would trigger the bug:
gl_ClipDistance[i] = gl_in[j].gl_ClipDistance[i];
This patch causes
lower_clip_distance_visitor::visit_leave(ir_assignment *) to call the
base class visitor, so that the right hand side of the assignment is
properly lowered.
Fixes piglit test:
- spec/glsl-1.50/execution/geometry/clip-distance-itemized-copy
Cc: Ian Romanick <idr@freedesktop.org>
Cc: "9.2" <mesa-stable@lists.freedesktop.org>
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-11-22 12:37:22 -08:00
|
|
|
/* First invoke the base class visitor. This causes handle_rvalue() to be
|
|
|
|
|
* called on ir->rhs and ir->condition.
|
|
|
|
|
*/
|
|
|
|
|
ir_rvalue_visitor::visit_leave(ir);
|
|
|
|
|
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->is_distance_vec8(ir->lhs) ||
|
|
|
|
|
this->is_distance_vec8(ir->rhs)) {
|
2016-05-14 11:37:48 +10:00
|
|
|
/* LHS or RHS of the assignment is the entire 1D gl_ClipDistance array
|
|
|
|
|
* (or a 1D slice of a 2D gl_ClipDistance input array). Since we are
|
|
|
|
|
* reshaping gl_ClipDistance from an array of floats to an array of
|
2013-02-15 09:30:51 -06:00
|
|
|
* vec4's, this isn't going to work as a bulk assignment anymore, so
|
|
|
|
|
* unroll it to element-by-element assignments and lower each of them.
|
2011-08-11 20:58:21 -07:00
|
|
|
*
|
|
|
|
|
* Note: to unroll into element-by-element assignments, we need to make
|
2013-05-08 10:59:47 -07:00
|
|
|
* clones of the LHS and RHS. This is safe because expressions and
|
|
|
|
|
* l-values are side-effect free.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
void *ctx = ralloc_parent(ir);
|
2013-02-15 09:30:51 -06:00
|
|
|
int array_size = ir->lhs->type->array_size();
|
2011-08-11 20:58:21 -07:00
|
|
|
for (int i = 0; i < array_size; ++i) {
|
|
|
|
|
ir_dereference_array *new_lhs = new(ctx) ir_dereference_array(
|
|
|
|
|
ir->lhs->clone(ctx, NULL), new(ctx) ir_constant(i));
|
|
|
|
|
ir_dereference_array *new_rhs = new(ctx) ir_dereference_array(
|
|
|
|
|
ir->rhs->clone(ctx, NULL), new(ctx) ir_constant(i));
|
2013-05-08 10:48:55 -07:00
|
|
|
this->handle_rvalue((ir_rvalue **) &new_rhs);
|
2013-03-22 17:42:38 -07:00
|
|
|
|
|
|
|
|
/* Handle the LHS after creating the new assignment. This must
|
|
|
|
|
* happen in this order because handle_rvalue may replace the old LHS
|
|
|
|
|
* with an ir_expression of ir_binop_vector_extract. Since this is
|
|
|
|
|
* not a valide l-value, this will cause an assertion in the
|
|
|
|
|
* ir_assignment constructor to fail.
|
|
|
|
|
*
|
|
|
|
|
* If this occurs, replace the mangled LHS with a dereference of the
|
|
|
|
|
* vector, and replace the RHS with an ir_triop_vector_insert.
|
|
|
|
|
*/
|
|
|
|
|
ir_assignment *const assign = new(ctx) ir_assignment(new_lhs, new_rhs);
|
|
|
|
|
this->handle_rvalue((ir_rvalue **) &assign->lhs);
|
|
|
|
|
this->fix_lhs(assign);
|
|
|
|
|
|
|
|
|
|
this->base_ir->insert_before(assign);
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
ir->remove();
|
2013-05-08 10:48:55 -07:00
|
|
|
|
|
|
|
|
return visit_continue;
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
/* Handle the LHS as if it were an r-value. Normally
|
|
|
|
|
* rvalue_visit(ir_assignment *) only visits the RHS, but we need to lower
|
|
|
|
|
* expressions in the LHS as well.
|
2013-03-22 17:42:38 -07:00
|
|
|
*
|
|
|
|
|
* This may cause the LHS to get replaced with an ir_expression of
|
|
|
|
|
* ir_binop_vector_extract. If this occurs, replace it with a dereference
|
|
|
|
|
* of the vector, and replace the RHS with an ir_triop_vector_insert.
|
2013-05-08 10:48:55 -07:00
|
|
|
*/
|
|
|
|
|
handle_rvalue((ir_rvalue **)&ir->lhs);
|
2013-03-22 17:42:38 -07:00
|
|
|
this->fix_lhs(ir);
|
|
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
return rvalue_visit(ir);
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Set up base_ir properly and call visit_leave() on a newly created
|
|
|
|
|
* ir_assignment node. This is used in cases where we have to insert an
|
|
|
|
|
* ir_assignment in a place where we know the hierarchical visitor won't see
|
|
|
|
|
* it.
|
|
|
|
|
*/
|
|
|
|
|
void
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::visit_new_assignment(ir_assignment *ir)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
|
|
|
|
ir_instruction *old_base_ir = this->base_ir;
|
|
|
|
|
this->base_ir = ir;
|
|
|
|
|
ir->accept(this);
|
|
|
|
|
this->base_ir = old_base_ir;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-05-14 11:37:48 +10:00
|
|
|
* If a 1D gl_ClipDistance variable appears as an argument in an ir_call
|
2013-02-15 09:30:51 -06:00
|
|
|
* expression, replace it with a temporary variable, and make sure the ir_call
|
|
|
|
|
* is preceded and/or followed by assignments that copy the contents of the
|
2016-05-14 11:37:48 +10:00
|
|
|
* temporary variable to and/or from gl_ClipDistance. Each of these
|
|
|
|
|
* assignments is then lowered to refer to gl_ClipDistanceMESA.
|
2013-02-15 09:30:51 -06:00
|
|
|
*
|
2016-05-14 11:37:48 +10:00
|
|
|
* We need to do a similar replacement for 2D gl_ClipDistance, however since
|
2013-02-15 09:30:51 -06:00
|
|
|
* it's an input, the only case we need to address is where a 1D slice of it
|
|
|
|
|
* is passed as an "in" parameter to an ir_call, e.g.:
|
|
|
|
|
*
|
|
|
|
|
* foo(gl_in[i].gl_ClipDistance)
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
|
|
|
|
ir_visitor_status
|
2016-05-08 22:44:04 +02:00
|
|
|
lower_distance_visitor::visit_leave(ir_call *ir)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
|
|
|
|
void *ctx = ralloc_parent(ir);
|
|
|
|
|
|
2011-09-20 18:08:11 -07:00
|
|
|
const exec_node *formal_param_node = ir->callee->parameters.head;
|
2011-08-11 20:58:21 -07:00
|
|
|
const exec_node *actual_param_node = ir->actual_parameters.head;
|
|
|
|
|
while (!actual_param_node->is_tail_sentinel()) {
|
|
|
|
|
ir_variable *formal_param = (ir_variable *) formal_param_node;
|
|
|
|
|
ir_rvalue *actual_param = (ir_rvalue *) actual_param_node;
|
|
|
|
|
|
|
|
|
|
/* Advance formal_param_node and actual_param_node now so that we can
|
|
|
|
|
* safely replace actual_param with another node, if necessary, below.
|
|
|
|
|
*/
|
|
|
|
|
formal_param_node = formal_param_node->next;
|
|
|
|
|
actual_param_node = actual_param_node->next;
|
|
|
|
|
|
2016-05-08 22:44:04 +02:00
|
|
|
if (this->is_distance_vec8(actual_param)) {
|
2016-05-14 11:37:48 +10:00
|
|
|
/* User is trying to pass the whole 1D gl_ClipDistance array (or a 1D
|
|
|
|
|
* slice of a 2D gl_ClipDistance array) to a function call. Since we
|
|
|
|
|
* are reshaping gl_ClipDistance from an array of floats to an array
|
2013-02-15 09:30:51 -06:00
|
|
|
* of vec4's, this isn't going to work anymore, so use a temporary
|
|
|
|
|
* array instead.
|
2011-08-11 20:58:21 -07:00
|
|
|
*/
|
2016-05-14 11:37:48 +10:00
|
|
|
ir_variable *temp_clip_distance = new(ctx) ir_variable(
|
|
|
|
|
actual_param->type, "temp_clip_distance", ir_var_temporary);
|
|
|
|
|
this->base_ir->insert_before(temp_clip_distance);
|
2011-08-11 20:58:21 -07:00
|
|
|
actual_param->replace_with(
|
2016-05-14 11:37:48 +10:00
|
|
|
new(ctx) ir_dereference_variable(temp_clip_distance));
|
2013-12-12 13:51:01 +02:00
|
|
|
if (formal_param->data.mode == ir_var_function_in
|
|
|
|
|
|| formal_param->data.mode == ir_var_function_inout) {
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Copy from gl_ClipDistance to the temporary before the call.
|
2011-08-11 20:58:21 -07:00
|
|
|
* Since we are going to insert this copy before the current
|
|
|
|
|
* instruction, we need to visit it afterwards to make sure it
|
|
|
|
|
* gets lowered.
|
|
|
|
|
*/
|
|
|
|
|
ir_assignment *new_assignment = new(ctx) ir_assignment(
|
2016-05-14 11:37:48 +10:00
|
|
|
new(ctx) ir_dereference_variable(temp_clip_distance),
|
2013-02-15 09:30:51 -06:00
|
|
|
actual_param->clone(ctx, NULL));
|
2011-08-11 20:58:21 -07:00
|
|
|
this->base_ir->insert_before(new_assignment);
|
|
|
|
|
this->visit_new_assignment(new_assignment);
|
|
|
|
|
}
|
2013-12-12 13:51:01 +02:00
|
|
|
if (formal_param->data.mode == ir_var_function_out
|
|
|
|
|
|| formal_param->data.mode == ir_var_function_inout) {
|
2016-05-14 11:37:48 +10:00
|
|
|
/* Copy from the temporary to gl_ClipDistance after the call.
|
2011-08-11 20:58:21 -07:00
|
|
|
* Since visit_list_elements() has already decided which
|
|
|
|
|
* instruction it's going to visit next, we need to visit
|
|
|
|
|
* afterwards to make sure it gets lowered.
|
|
|
|
|
*/
|
|
|
|
|
ir_assignment *new_assignment = new(ctx) ir_assignment(
|
2013-02-15 09:30:51 -06:00
|
|
|
actual_param->clone(ctx, NULL),
|
2016-05-14 11:37:48 +10:00
|
|
|
new(ctx) ir_dereference_variable(temp_clip_distance));
|
2011-08-11 20:58:21 -07:00
|
|
|
this->base_ir->insert_after(new_assignment);
|
|
|
|
|
this->visit_new_assignment(new_assignment);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-05-08 10:48:55 -07:00
|
|
|
return rvalue_visit(ir);
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|
|
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
namespace {
|
|
|
|
|
class lower_distance_visitor_counter : public ir_rvalue_visitor {
|
|
|
|
|
public:
|
|
|
|
|
explicit lower_distance_visitor_counter(void)
|
|
|
|
|
: in_clip_size(0), in_cull_size(0),
|
|
|
|
|
out_clip_size(0), out_cull_size(0)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual ir_visitor_status visit(ir_variable *);
|
|
|
|
|
virtual void handle_rvalue(ir_rvalue **rvalue);
|
|
|
|
|
|
|
|
|
|
int in_clip_size;
|
|
|
|
|
int in_cull_size;
|
|
|
|
|
int out_clip_size;
|
|
|
|
|
int out_cull_size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* Count gl_ClipDistance and gl_CullDistance sizes.
|
|
|
|
|
*/
|
|
|
|
|
ir_visitor_status
|
|
|
|
|
lower_distance_visitor_counter::visit(ir_variable *ir)
|
|
|
|
|
{
|
|
|
|
|
int *clip_size, *cull_size;
|
|
|
|
|
|
|
|
|
|
if (!ir->name)
|
|
|
|
|
return visit_continue;
|
|
|
|
|
|
|
|
|
|
if (ir->data.mode == ir_var_shader_out) {
|
|
|
|
|
clip_size = &out_clip_size;
|
|
|
|
|
cull_size = &out_cull_size;
|
|
|
|
|
} else if (ir->data.mode == ir_var_shader_in) {
|
|
|
|
|
clip_size = &in_clip_size;
|
|
|
|
|
cull_size = &in_cull_size;
|
|
|
|
|
} else
|
|
|
|
|
return visit_continue;
|
|
|
|
|
|
|
|
|
|
if (ir->type->is_unsized_array())
|
|
|
|
|
return visit_continue;
|
|
|
|
|
|
|
|
|
|
if (*clip_size == 0) {
|
|
|
|
|
if (!strcmp(ir->name, "gl_ClipDistance")) {
|
|
|
|
|
if (!ir->type->fields.array->is_array())
|
|
|
|
|
*clip_size = ir->type->array_size();
|
|
|
|
|
else
|
|
|
|
|
*clip_size = ir->type->fields.array->array_size();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*cull_size == 0) {
|
|
|
|
|
if (!strcmp(ir->name, "gl_CullDistance")) {
|
|
|
|
|
if (!ir->type->fields.array->is_array())
|
|
|
|
|
*cull_size = ir->type->array_size();
|
|
|
|
|
else
|
|
|
|
|
*cull_size = ir->type->fields.array->array_size();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return visit_continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
lower_distance_visitor_counter::handle_rvalue(ir_rvalue **rv)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2011-08-11 20:58:21 -07:00
|
|
|
|
|
|
|
|
bool
|
2016-05-16 08:47:32 +10:00
|
|
|
lower_clip_cull_distance(struct gl_shader_program *prog, gl_shader *shader)
|
2011-08-11 20:58:21 -07:00
|
|
|
{
|
2016-05-16 08:47:32 +10:00
|
|
|
int clip_size, cull_size;
|
|
|
|
|
|
|
|
|
|
lower_distance_visitor_counter count;
|
|
|
|
|
visit_list_elements(&count, shader->ir);
|
|
|
|
|
|
|
|
|
|
clip_size = MAX2(count.in_clip_size, count.out_clip_size);
|
|
|
|
|
cull_size = MAX2(count.in_cull_size, count.out_cull_size);
|
2011-08-11 20:58:21 -07:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
if (clip_size == 0 && cull_size == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
lower_distance_visitor v(shader->Stage, "gl_ClipDistance", clip_size + cull_size, 0);
|
2016-05-14 11:37:48 +10:00
|
|
|
visit_list_elements(&v, shader->ir);
|
2012-12-04 11:11:02 -08:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
lower_distance_visitor v2(shader->Stage, "gl_CullDistance", &v, clip_size);
|
|
|
|
|
visit_list_elements(&v2, shader->ir);
|
|
|
|
|
|
|
|
|
|
if (v2.new_distance_out_var)
|
|
|
|
|
shader->symbols->add_variable(v2.new_distance_out_var);
|
|
|
|
|
if (v2.new_distance_in_var)
|
|
|
|
|
shader->symbols->add_variable(v2.new_distance_in_var);
|
2011-08-11 20:58:21 -07:00
|
|
|
|
2016-05-16 08:47:32 +10:00
|
|
|
return v2.progress;
|
2011-08-11 20:58:21 -07:00
|
|
|
}
|