[Mesa-dev] [PATCH 13/21] glsl: enable lowering of varyings with explicit component
Timothy Arceri
timothy.arceri at collabora.com
Mon Dec 21 22:02:00 PST 2015
---
src/glsl/ir_optimization.h | 3 ++-
src/glsl/link_varyings.cpp | 6 ++++--
src/glsl/lower_packed_varyings.cpp | 33 ++++++++++++++++++++++++---------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 19ebf86..eab76ff 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -129,7 +129,8 @@ void lower_ubo_reference(struct gl_shader *shader);
void lower_packed_varyings(void *mem_ctx,
unsigned locations_used, ir_variable_mode mode,
unsigned gs_input_vertices, gl_shader *shader,
- bool disable_varying_packing);
+ bool disable_varying_packing,
+ bool has_enhanced_layouts);
bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index);
bool lower_vector_derefs(gl_shader *shader);
void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
diff --git a/src/glsl/link_varyings.cpp b/src/glsl/link_varyings.cpp
index dd58707..543153e 100644
--- a/src/glsl/link_varyings.cpp
+++ b/src/glsl/link_varyings.cpp
@@ -1825,7 +1825,8 @@ assign_varying_locations(struct gl_context *ctx,
remove_unused_shader_inputs_and_outputs(prog, producer,
ir_var_shader_out);
lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_out,
- 0, producer, disable_varying_packing);
+ 0, producer, disable_varying_packing,
+ ctx->Extensions.ARB_enhanced_layouts);
}
if (consumer) {
@@ -1833,7 +1834,8 @@ assign_varying_locations(struct gl_context *ctx,
ir_var_shader_in);
lower_packed_varyings(mem_ctx, slots_used, ir_var_shader_in,
consumer_vertices, consumer,
- disable_varying_packing);
+ disable_varying_packing,
+ ctx->Extensions.ARB_enhanced_layouts);
}
if (consumer && producer) {
diff --git a/src/glsl/lower_packed_varyings.cpp b/src/glsl/lower_packed_varyings.cpp
index 2899846..cfba9af 100644
--- a/src/glsl/lower_packed_varyings.cpp
+++ b/src/glsl/lower_packed_varyings.cpp
@@ -169,7 +169,8 @@ public:
unsigned gs_input_vertices,
exec_list *out_instructions,
exec_list *out_variables,
- bool disable_varying_packing);
+ bool disable_varying_packing,
+ bool has_enhanced_layouts);
void run(struct gl_shader *shader);
@@ -236,6 +237,7 @@ private:
exec_list *out_variables;
bool disable_varying_packing;
+ bool has_enhanced_layouts;
};
} /* anonymous namespace */
@@ -243,7 +245,8 @@ private:
lower_packed_varyings_visitor::lower_packed_varyings_visitor(
void *mem_ctx, unsigned locations_used, ir_variable_mode mode,
unsigned gs_input_vertices, exec_list *out_instructions,
- exec_list *out_variables, bool disable_varying_packing)
+ exec_list *out_variables, bool disable_varying_packing,
+ bool has_enhanced_layouts)
: mem_ctx(mem_ctx),
locations_used(locations_used),
packed_varyings((ir_variable **)
@@ -253,7 +256,8 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor(
gs_input_vertices(gs_input_vertices),
out_instructions(out_instructions),
out_variables(out_variables),
- disable_varying_packing(disable_varying_packing)
+ disable_varying_packing(disable_varying_packing),
+ has_enhanced_layouts(has_enhanced_layouts)
{
}
@@ -673,15 +677,24 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
bool
lower_packed_varyings_visitor::needs_lowering(ir_variable *var)
{
- /* Things composed of vec4's and varyings with explicitly assigned
- * locations don't need lowering. Everything else does.
+ /* Don't lower varying with explicit location unless ARB_enhanced_layouts
+ * is enabled, also don't try to pack structs with explicit location as
+ * they don't support the component layout qualifier anyway.
*/
- if (var->data.explicit_location)
+ if (var->data.explicit_location && (!has_enhanced_layouts ||
+ var->type->without_array()->is_record())) {
return false;
+ }
- if (disable_varying_packing)
+ /* Don't disable packing for explicit locations when ARB_enhanced_layouts
+ * is supported.
+ */
+ if (disable_varying_packing && !var->data.explicit_location)
return false;
+ /* Things composed of vec4's and doubles don't need lowering everything
+ * else does.
+ */
const glsl_type *type = var->type->without_array();
if (type->vector_elements == 4 && !type->is_double())
return false;
@@ -735,7 +748,8 @@ lower_packed_varyings_gs_splicer::visit_leave(ir_emit_vertex *ev)
void
lower_packed_varyings(void *mem_ctx, unsigned locations_used,
ir_variable_mode mode, unsigned gs_input_vertices,
- gl_shader *shader, bool disable_varying_packing)
+ gl_shader *shader, bool disable_varying_packing,
+ bool has_enhanced_layouts)
{
exec_list *instructions = shader->ir;
ir_function *main_func = shader->symbols->get_function("main");
@@ -747,7 +761,8 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
gs_input_vertices,
&new_instructions,
&new_variables,
- disable_varying_packing);
+ disable_varying_packing,
+ has_enhanced_layouts);
visitor.run(shader);
if (mode == ir_var_shader_out) {
if (shader->Stage == MESA_SHADER_GEOMETRY) {
--
2.4.3
More information about the mesa-dev
mailing list