Valgrind massif results for a trimmed apitrace of dota2:
n time(i) total(B) useful-heap(B) extra-heap(B) stacks(B)
Before (32-bit): 74 40,578,719,715 67,762,208 62,263,404 5,498,804 0
After (32-bit): 52 40,565,579,466 66,359,800 61,187,818 5,171,982 0
Before (64-bit): 74 37,129,541,061 95,195,160 87,369,671 7,825,489 0
After (64-bit): 76 37,134,691,404 93,271,352 85,900,223 7,371,129 0
A real savings of 1.0MiB on 32-bit and 1.4MiB on 64-bit.
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
new(shader) _mesa_glsl_parse_state(ctx, shader->Stage, shader);
const char *source = shader->Source;
+ if (ctx->Const.GenerateTemporaryNames)
+ ir_variable::temporaries_allocate_names = true;
+
state->error = glcpp_preprocess(state, &source, &state->info_log,
&ctx->Extensions, ctx);
}
+bool ir_variable::temporaries_allocate_names = false;
+
const char ir_variable::tmp_name[] = "compiler_temp";
ir_variable::ir_variable(const struct glsl_type *type, const char *name,
{
this->type = type;
+ if (mode == ir_var_temporary && !ir_variable::temporaries_allocate_names)
+ name = NULL;
+
/* The ir_variable clone method may call this constructor with name set to
* tmp_name.
*/
* Name used for anonymous compiler temporaries
*/
static const char tmp_name[];
+
+public:
+ /**
+ * Should the construct keep names for ir_var_temporary variables?
+ *
+ * When this global is false, names passed to the constructor for
+ * \c ir_var_temporary variables will be dropped. Instead, the variable will
+ * be named "compiler_temp". This name will be in static storage.
+ *
+ * \warning
+ * \b NEVER change the mode of an \c ir_var_temporary.
+ *
+ * \warning
+ * This variable is \b not thread-safe. It is global, \b not
+ * per-context. It begins life false. A context can, at some point, make
+ * it true. From that point on, it will be true forever. This should be
+ * okay since it will only be set true while debugging.
+ */
+ static bool temporaries_allocate_names;
};
/**
initialize_context_to_defaults(ctx, API_OPENGL_COMPAT);
ctx->Driver.NewShader = _mesa_new_shader;
+ ir_variable::temporaries_allocate_names = true;
struct gl_shader *shader = rzalloc(NULL, struct gl_shader);
shader->Type = shader_type;