Skip to content
This repository was archived by the owner on Dec 8, 2025. It is now read-only.
This repository was archived by the owner on Dec 8, 2025. It is now read-only.

glsl-reduce enhancement: based on perses #1179

@AaronGhost

Description

@AaronGhost

I have been experimenting with both glsl-reduce and perses as reducers. It seems that Perses performs more reduction opportunities than glsl-reduce, especially in reducing more aggressively array indexes. Please find below some examples of structures reduced first with glsl-reduce and then with perses.

  • Reducing ternary operators in array indexes

glsl-reduce

void main()
{
 ext_2[(all(bvec2(true)) ? (+ abs(ext_1[1])) : (ext_0 & -- ext_2[2]))] |= 1;
}

perses

void main()
{
 ext_2[abs(ext_1[1])] |= 1;
}
  • Removing the outer array in an array index expression

glsl-reduce

void main()
{
 ext_3[(+ + (ext_1 /= (ext_5[2086006349])))] = 1u;
 ++ ext_4[int(var_0[ext_4[(ext_4[ext_4[(ext_4[ext_4[ext_4[1893896488]]])]])]].ttt)];
}

perses

void main()
{
 ext_1/=  ext_5[2086006349];
 ++ ext_4[int(var_0[ext_4[1893896488]])];
}
  • Reducing complicated swizzles (some can be removed altogether)

glsl-reduce

void main()
{
  ivec4 var_1 = ivec4(- 2147483634);
 (ext_3[ext_7]) = bitfieldExtract(114u, 1, (~ ext_1) / var_1.ttp.yx.x);
}

perses

void main()
{
  ivec4 var_1 = ivec4(- 2147483634);
  ext_3[ext_7]  = bitfieldExtract(114u, 1,  ~ ext_1  / var_1.x);
}
  • Reducing the number of parameters in type constructors

glsl-reduce

void main()
{
 while(1u + ext_3 <= uint(uvec4(bvec2(false), 1u, true)))
  {
   ext_10 = 1u;
  }
}

perses

 void main()
{
 while(1u + ext_3 <= uint(false))
 {
   ext_10 = 1u;
 }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions