[Mesa-dev] [PATCH 01/23] glsl: remember per-component vertex streams for packed varyings
Nicolai Hähnle
nhaehnle at gmail.com
Wed Nov 30 13:35:03 UTC 2016
From: Nicolai Hähnle <nicolai.haehnle at amd.com>
---
src/compiler/glsl/ir.h | 3 +++
src/compiler/glsl/ir_print_visitor.cpp | 14 ++++++++++++--
src/compiler/glsl/lower_packed_varyings.cpp | 9 +++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 24f510e..df3ccfd 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -910,20 +910,23 @@ public:
/**
* for glsl->tgsi/mesa IR we need to store the index into the
* parameters for uniforms, initially the code overloaded location
* but this causes problems with indirect samplers and AoA.
* This is assigned in _mesa_generate_parameters_list_for_uniforms.
*/
int param_index;
/**
* Vertex stream output identifier.
+ *
+ * For packed outputs, bit 31 is set and bits [2*i+1,2*i] indicate the
+ * stream of the i-th component.
*/
unsigned stream;
/**
* Atomic, transform feedback or block member offset.
*/
unsigned offset;
/**
* Highest element accessed with a constant expression array index
diff --git a/src/compiler/glsl/ir_print_visitor.cpp b/src/compiler/glsl/ir_print_visitor.cpp
index 703169e..2b77c14 100644
--- a/src/compiler/glsl/ir_print_visitor.cpp
+++ b/src/compiler/glsl/ir_print_visitor.cpp
@@ -170,37 +170,47 @@ void ir_print_visitor::visit(ir_variable *ir)
snprintf(binding, sizeof(binding), "binding=%i ", ir->data.binding);
char loc[32] = {0};
if (ir->data.location != -1)
snprintf(loc, sizeof(loc), "location=%i ", ir->data.location);
char component[32] = {0};
if (ir->data.explicit_component)
snprintf(component, sizeof(component), "component=%i ", ir->data.location_frac);
+ char stream[32] = {0};
+ if (ir->data.stream & (1u << 31)) {
+ if (ir->data.stream & ~(1u << 31)) {
+ snprintf(stream, sizeof(stream), "stream(%u,%u,%u,%u)",
+ ir->data.stream & 3, (ir->data.stream >> 2) & 3,
+ (ir->data.stream >> 4) & 3, (ir->data.stream >> 6) & 3);
+ }
+ } else if (ir->data.stream) {
+ snprintf(stream, sizeof(stream), "stream%u", ir->data.stream);
+ }
+
const char *const cent = (ir->data.centroid) ? "centroid " : "";
const char *const samp = (ir->data.sample) ? "sample " : "";
const char *const patc = (ir->data.patch) ? "patch " : "";
const char *const inv = (ir->data.invariant) ? "invariant " : "";
const char *const prec = (ir->data.precise) ? "precise " : "";
const char *const mode[] = { "", "uniform ", "shader_storage ",
"shader_shared ", "shader_in ", "shader_out ",
"in ", "out ", "inout ",
"const_in ", "sys ", "temporary " };
STATIC_ASSERT(ARRAY_SIZE(mode) == ir_var_mode_count);
- const char *const stream [] = {"", "stream1 ", "stream2 ", "stream3 "};
const char *const interp[] = { "", "smooth", "flat", "noperspective" };
STATIC_ASSERT(ARRAY_SIZE(interp) == INTERP_MODE_COUNT);
fprintf(f, "(%s%s%s%s%s%s%s%s%s%s%s) ",
binding, loc, component, cent, samp, patc, inv, prec, mode[ir->data.mode],
- stream[ir->data.stream],
+ stream,
interp[ir->data.interpolation]);
print_type(f, ir->type);
fprintf(f, " %s)", unique_name(ir));
}
void ir_print_visitor::visit(ir_function_signature *ir)
{
_mesa_symbol_table_push_scope(symbols);
diff --git a/src/compiler/glsl/lower_packed_varyings.cpp b/src/compiler/glsl/lower_packed_varyings.cpp
index b16f25f..7a2f187 100644
--- a/src/compiler/glsl/lower_packed_varyings.cpp
+++ b/src/compiler/glsl/lower_packed_varyings.cpp
@@ -524,20 +524,28 @@ lower_packed_varyings_visitor::lower_rvalue(ir_rvalue *rvalue,
*/
unsigned swizzle_values[4] = { 0, 0, 0, 0 };
unsigned components = rvalue->type->vector_elements * dmul;
unsigned location = fine_location / 4;
unsigned location_frac = fine_location % 4;
for (unsigned i = 0; i < components; ++i)
swizzle_values[i] = i + location_frac;
ir_dereference *packed_deref =
this->get_packed_varying_deref(location, unpacked_var, name,
vertex_index);
+ if (unpacked_var->data.stream != 0) {
+ assert(unpacked_var->data.stream < 4);
+ ir_variable *packed_var = packed_deref->variable_referenced();
+ for (unsigned i = 0; i < components; ++i) {
+ packed_var->data.stream |=
+ unpacked_var->data.stream << (2 * (location_frac + i));
+ }
+ }
ir_swizzle *swizzle = new(this->mem_ctx)
ir_swizzle(packed_deref, swizzle_values, components);
if (this->mode == ir_var_shader_out) {
this->bitwise_assign_pack(swizzle, rvalue);
} else {
this->bitwise_assign_unpack(rvalue, swizzle);
}
return fine_location + components;
}
}
@@ -632,20 +640,21 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
packed_var->data.max_array_access = this->gs_input_vertices - 1;
}
packed_var->data.centroid = unpacked_var->data.centroid;
packed_var->data.sample = unpacked_var->data.sample;
packed_var->data.patch = unpacked_var->data.patch;
packed_var->data.interpolation = packed_type == glsl_type::ivec4_type
? unsigned(INTERP_MODE_FLAT) : unpacked_var->data.interpolation;
packed_var->data.location = location;
packed_var->data.precision = unpacked_var->data.precision;
packed_var->data.always_active_io = unpacked_var->data.always_active_io;
+ packed_var->data.stream = 1u << 31;
unpacked_var->insert_before(packed_var);
this->packed_varyings[slot] = packed_var;
} else {
/* For geometry shader inputs, only update the packed variable name the
* first time we visit each component.
*/
if (this->gs_input_vertices == 0 || vertex_index == 0) {
ir_variable *var = this->packed_varyings[slot];
if (var->is_name_ralloced())
--
2.7.4
More information about the mesa-dev
mailing list