[Mesa-dev] [PATCH 1/5] glsl: Make opt_constant_variable() bail in useless cases.

Kai Wasserbäch kai at dev.carbon-project.org
Mon May 9 15:42:28 UTC 2016


Hey Kenneth,
while hunting the cause of fdo#95285 down, I tested these patches from your
tombraider-2 branch. But when applied the game started crashing, see
<https://bugs.freedesktop.org/show_bug.cgi?id=95285#c4>. Now, it might be that
the omitted "glsl: Make lower_const_arrays_to_uniforms work directly on
constants." was the cause for that and you left it out because of that. If not,
please have a look at <https://bugs.freedesktop.org/show_bug.cgi?id=95285#c4>.
If there is some additional test I should run, let me know.

Cheers,
Kai


Kenneth Graunke wrote on 09.05.2016 08:50:
> The pass ultimately skips over any entries with assignment_count != 1,
> so there's no need to do further work once we've determined that there
> are multiple assignments.
> 
> The constant value could be a large array (i.e. uvec4[327]), at which
> point skipping the constant_expression_value() call (and the clone()
> call within) can save us piles of memory.
> 
> No change in shader-db.
> 
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
>  src/compiler/glsl/opt_constant_variable.cpp | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/compiler/glsl/opt_constant_variable.cpp b/src/compiler/glsl/opt_constant_variable.cpp
> index 3ddb129..1c06ffe 100644
> --- a/src/compiler/glsl/opt_constant_variable.cpp
> +++ b/src/compiler/glsl/opt_constant_variable.cpp
> @@ -102,6 +102,13 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
>     assert(entry);
>     entry->assignment_count++;
>  
> +   /* If there's more than one assignment, don't bother - we won't do anything
> +    * with this variable anyway, and continuing just wastes memory cloning
> +    * constant expressions.
> +    */
> +   if (entry->assignment_count > 1)
> +      return visit_continue;
> +
>     /* If it's already constant, don't do the work. */
>     if (entry->var->constant_value)
>        return visit_continue;
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 630 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160509/d0f9afdd/attachment.sig>


More information about the mesa-dev mailing list