@@ -43,6 +43,8 @@ class ClusterFit : ColourFit
4343 Vector4 m_xsum_wsum ;
4444 Vector4 m_metric ;
4545 Vector4 m_besterror ;
46+ static Vector4 grid = new Vector4 ( 31.0f , 63.0f , 31.0f , 0 ) ;
47+ static Vector4 gridrcp = new Vector4 ( 1.0f / 31.0f , 1.0f / 63.0f , 1.0f / 31.0f , 0.0f ) ;
4648
4749 private static void swap < T > ( ref T a , ref T b )
4850{
@@ -144,12 +146,8 @@ public unsafe override void Compress3( byte* block )
144146 // declare variables
145147 int count = m_colours . GetCount ( ) ;
146148 Vector4 two = Vector4 . one * ( 2.0f ) ;
147- Vector4 one = Vector4 . one * ( 1.0f ) ;
148149 Vector4 half_half2 = new Vector4 ( 0.5f , 0.5f , 0.5f , 0.25f ) ;
149- Vector4 zero = Vector4 . zero ;
150150 Vector4 half = Vector4 . one * ( 0.5f ) ;
151- Vector4 grid = new Vector4 ( 31.0f , 63.0f , 31.0f , 0.0f ) ;
152- Vector4 gridrcp = new Vector4 ( 1.0f / 31.0f , 1.0f / 63.0f , 1.0f / 31.0f , 0.0f ) ;
153151
154152 // prepare an ordering using the principle axis
155153 ructOrdering ( m_principle , 0 ) ;
@@ -192,8 +190,8 @@ public unsafe override void Compress3( byte* block )
192190 Vector4 b = Vector4 . Scale ( alphax_sum . NegativeMultiplySubtract ( alphabeta_sum , Vector4 . Scale ( betax_sum , alpha2_sum ) ) , factor ) ;
193191
194192 // clamp to the grid
195- a = Vector4 . Min ( one , Vector4 . Max ( zero , a ) ) ;
196- b = Vector4 . Min ( one , Vector4 . Max ( zero , b ) ) ;
193+ a = Vector4 . Min ( Vector4 . one , Vector4 . Max ( Vector4 . zero , a ) ) ;
194+ b = Vector4 . Min ( Vector4 . one , Vector4 . Max ( Vector4 . zero , b ) ) ;
197195 a = Vector4 . Scale ( ( grid . MultiplyAdd ( a , half ) ) . Truncate ( ) , gridrcp ) ;
198196 b = Vector4 . Scale ( ( grid . MultiplyAdd ( b , half ) ) . Truncate ( ) , gridrcp ) ;
199197
@@ -275,14 +273,10 @@ public unsafe override void Compress4( byte* block )
275273 // declare variables
276274 int count = m_colours . GetCount ( ) ;
277275 Vector4 two = Vector4 . one * ( 2.0f ) ;
278- Vector4 one = Vector4 . one ;
279276 Vector4 onethird_onethird2 = new Vector4 ( 1.0f / 3.0f , 1.0f / 3.0f , 1.0f / 3.0f , 1.0f / 9.0f ) ;
280277 Vector4 twothirds_twothirds2 = new Vector4 ( 2.0f / 3.0f , 2.0f / 3.0f , 2.0f / 3.0f , 4.0f / 9.0f ) ;
281278 Vector4 twonineths = Vector4 . one * ( 2.0f / 9.0f ) ;
282- Vector4 zero = Vector4 . zero ;
283279 Vector4 half = Vector4 . one * ( 0.5f ) ;
284- Vector4 grid = new Vector4 ( 31.0f , 63.0f , 31.0f , 0.0f ) ;
285- Vector4 gridrcp = new Vector4 ( 1.0f / 31.0f , 1.0f / 63.0f , 1.0f / 31.0f , 0.0f ) ;
286280
287281 // prepare an ordering using the principle axis
288282 ructOrdering ( m_principle , 0 ) ;
@@ -329,8 +323,8 @@ public unsafe override void Compress4( byte* block )
329323 Vector4 b = Vector4 . Scale ( alphax_sum . NegativeMultiplySubtract ( alphabeta_sum , Vector4 . Scale ( betax_sum , alpha2_sum ) ) , factor ) ;
330324
331325 // clamp to the grid
332- a = Vector4 . Min ( one , Vector4 . Max ( zero , a ) ) ;
333- b = Vector4 . Min ( one , Vector4 . Max ( zero , b ) ) ;
326+ a = Vector4 . Min ( Vector4 . one , Vector4 . Max ( Vector4 . zero , a ) ) ;
327+ b = Vector4 . Min ( Vector4 . one , Vector4 . Max ( Vector4 . zero , b ) ) ;
334328 a = Vector4 . Scale ( ( grid . MultiplyAdd ( a , half ) ) . Truncate ( ) , gridrcp ) ;
335329 b = Vector4 . Scale ( ( grid . MultiplyAdd ( b , half ) ) . Truncate ( ) , gridrcp ) ;
336330
0 commit comments