[Mesa-dev] [PATCH 18/26] glsl: make needs_lowering() a shared packing helper function
Timothy Arceri
timothy.arceri at collabora.com
Mon Feb 29 01:17:58 UTC 2016
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
Reviewed-by: Edward O'Callaghan <eocallaghan at alterapraxis.com>
---
src/compiler/glsl/lower_packed_varyings.cpp | 55 ++++++++++++++---------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/src/compiler/glsl/lower_packed_varyings.cpp b/src/compiler/glsl/lower_packed_varyings.cpp
index 5d5b563..1ad6158 100644
--- a/src/compiler/glsl/lower_packed_varyings.cpp
+++ b/src/compiler/glsl/lower_packed_varyings.cpp
@@ -152,6 +152,32 @@
using namespace ir_builder;
+static bool
+needs_lowering(ir_variable *var, bool has_enhanced_layouts,
+ bool disable_varying_packing)
+{
+ /* 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 && (!has_enhanced_layouts ||
+ var->type->without_array()->is_record())) {
+ return false;
+ }
+
+ /* 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 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;
+ return true;
+}
+
namespace {
/**
@@ -191,7 +217,6 @@ private:
ir_variable *unpacked_var,
const char *name,
unsigned vertex_index);
- bool needs_lowering(ir_variable *var);
/**
* Memory context used to allocate new instructions for the shader.
@@ -275,7 +300,7 @@ lower_packed_varyings_visitor::run(struct gl_shader *shader)
if (var->data.mode != this->mode ||
var->data.location < (int) this->base_location ||
- !this->needs_lowering(var))
+ !needs_lowering(var, has_enhanced_layouts, disable_varying_packing))
continue;
/* This lowering pass is only capable of packing floats and ints
@@ -677,32 +702,6 @@ lower_packed_varyings_visitor::get_packed_varying_deref(
return deref;
}
-bool
-lower_packed_varyings_visitor::needs_lowering(ir_variable *var)
-{
- /* 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 && (!has_enhanced_layouts ||
- var->type->without_array()->is_record())) {
- return false;
- }
-
- /* 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 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;
- return true;
-}
-
-
/**
* Visitor that splices varying packing code before every use of EmitVertex()
* in a geometry shader.
--
2.5.0
More information about the mesa-dev
mailing list