Add strided generators
This PR adds strided generators, for generating noise corresponding to pre-made spatial points.
I modified FastNoiseCpp11Include test temporarily, and tested with a 4x4 position grid:
0,0: 0 vs 0
1,0: -0.209467 vs 0.125916
2,0: 0.424659 vs -0.209467
3,0: -0.15126 vs -0.220221
0,1: 0.125916 vs 0.424659
1,1: 0.327784 vs 0.000303611
2,1: 0.019688 vs -0.15126
3,1: -0.0671406 vs 0
0,2: -0.220221 vs -0.220221
1,2: 0.22565 vs 0.019688
2,2: 0.305475 vs 0.22565
3,2: 0.0472323 vs 0.305475
0,3: 0.000303611 vs 0.305475
1,3: 0.0469043 vs -0.091646
2,3: -0.091646 vs 0.0472323
3,3: 0.0466066 vs 0.424659
where the left column values are generated with GenUniformGrid2D and the right with GenStridedArray2D. They are indeed different at some indices, and I'm not sure why. Here are the calls:
FastNoise::Generator::Vector2 posArray[size * size];
for( int y = 0; y < size; y++ )
{
for( int x = 0; x < size; x++ )
{
posArray[y * size + x].x = (float)x;
posArray[y * size + x].y = (float)y;
}
}
node->GenUniformGrid2D( noise, 0, 0, size, size, 1.0f, 1337 );
node->GenStridedArray2D( noise2, size * size, posArray, 1337 );
Oh, I see the issue now. Load_f32 is assuming contiguous values, and we need to gather instead of load
I've updated the code to add a FS_Gather_f32, and it is now producing expected results:
256
0,0: 0 vs 0
1,0: -0.209467 vs -0.209467
2,0: 0.424659 vs 0.424659
3,0: -0.15126 vs -0.15126
0,1: 0.125916 vs 0.125916
1,1: 0.327784 vs 0.327784
2,1: 0.019688 vs 0.019688
3,1: -0.0671406 vs -0.0671406
0,2: -0.220221 vs -0.220221
1,2: 0.22565 vs 0.22565
2,2: 0.305475 vs 0.305475
3,2: 0.0472323 vs 0.0472323
0,3: 0.000303611 vs 0.000303611
1,3: 0.0469043 vs 0.0469043
2,3: -0.091646 vs -0.091646
3,3: 0.0466066 vs 0.0466066
I can only test on Win32 with AVX2, and this likely needs to be tested elsewhere
Thanks, I don't think I will pull this into the current main branch. I'm working on the 1.0 release in the NewFastSIMD branch which hopefully can be released soon. So I will look to integrate it into there
Thanks, I don't think I will pull this into the current main branch. I'm working on the 1.0 release in the NewFastSIMD branch which hopefully can be released soon. So I will look to integrate it into there
SGTM 👍