Skip to content

Commit

Permalink
Workaround MoltenVK issue with median3.
Browse files Browse the repository at this point in the history
  • Loading branch information
Themaister committed Jun 3, 2024
1 parent e564cbc commit ffc0d86
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions parallel-rdp/shaders/vi_divot.frag
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void swap(inout uint a, inout uint b)
b = tmp;
}

uint median3(uint left, uint center, uint right)
// Workaround Metal using median3.
uint Median3(uint left, uint center, uint right)
{
if (left < center)
swap(left, center);
Expand All @@ -65,9 +66,9 @@ void main()
else
{
// Median filter. TODO: Optimize with mid3?
uint r = median3(left.r, mid.r, right.r);
uint g = median3(left.g, mid.g, right.g);
uint b = median3(left.b, mid.b, right.b);
uint r = Median3(left.r, mid.r, right.r);
uint g = Median3(left.g, mid.g, right.g);
uint b = Median3(left.b, mid.b, right.b);
FragColor = uvec4(r, g, b, mid.a);
}

Expand All @@ -83,10 +84,10 @@ void main()
else
{
// Median filter. TODO: Optimize with mid3?
uint r = median3(left.r, mid.r, right.r);
uint g = median3(left.g, mid.g, right.g);
uint b = median3(left.b, mid.b, right.b);
uint r = Median3(left.r, mid.r, right.r);
uint g = Median3(left.g, mid.g, right.g);
uint b = Median3(left.b, mid.b, right.b);
FragColorFetchBug = uvec4(r, g, b, mid.a);
}
#endif
}
}

0 comments on commit ffc0d86

Please sign in to comment.