[Mesa-dev] [PATCH] glsl: Fold implementation of ir_dereference_record::constant_referenced into wrapper
Ian Romanick
idr at freedesktop.org
Wed Mar 12 16:10:09 PDT 2014
From: Ian Romanick <ian.d.romanick at intel.com>
v2: Don't shadow the variable 'deref' from a higher scope.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/glsl/ir_constant_expression.cpp | 39 +++++++++++++++++++++----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/src/glsl/ir_constant_expression.cpp b/src/glsl/ir_constant_expression.cpp
index c013dfd..2e60363 100644
--- a/src/glsl/ir_constant_expression.cpp
+++ b/src/glsl/ir_constant_expression.cpp
@@ -412,10 +412,28 @@ constant_referenced(const ir_dereference *deref,
store, offset);
break;
- case ir_type_dereference_record:
- ((ir_dereference_record *) deref)->constant_referenced(variable_context,
- store, offset);
+ case ir_type_dereference_record: {
+ const ir_dereference_record *const dr =
+ (const ir_dereference_record *) deref;
+
+ const ir_dereference *const rec_deref = dr->record->as_dereference();
+ if (!rec_deref)
+ break;
+
+ ir_constant *substore;
+ int suboffset;
+
+ if (!constant_referenced(rec_deref, variable_context, substore,
+ suboffset))
+ break;
+
+ /* Since we're dropping it on the floor...
+ */
+ assert(suboffset == 0);
+
+ store = substore->get_record_field(dr->field);
break;
+ }
case ir_type_dereference_variable: {
const ir_dereference_variable *const dv =
@@ -493,20 +511,7 @@ void
ir_dereference_record::constant_referenced(struct hash_table *variable_context,
ir_constant *&store, int &offset) const
{
- ir_constant *substore;
- int suboffset;
- const ir_dereference *deref = record->as_dereference();
- if (!deref) {
- store = 0;
- offset = 0;
- return;
- }
-
- if (!::constant_referenced(deref, variable_context, substore, suboffset))
- return;
-
- store = substore->get_record_field(field);
- offset = 0;
+ ::constant_referenced(this, variable_context, store, offset);
}
/*@}*/
--
1.8.1.4
More information about the mesa-dev
mailing list