I am trying to take one big array of pixels and split it up so that I have 4 arrays instead. One for red,blue,green and alpha.
Green, red and alpha is working, but that data for blue is wrong, which I find weird considering I am doing exactly the same for all the colours
Here is my code:
b,g,r,t are class variablesCode:/ Create SSE data // Test sprite is 64*64 //64 * 64 = 4096 __declspec(align(16)) unsigned short blue[4096]; __declspec(align(16)) unsigned short green[4096]; __declspec(align(16)) unsigned short red[4096]; __declspec(align(16)) unsigned short trans[4096]; // Pointer to the original spritedata BYTE *texture = spriteData; // Splitt the data up so that we have each colour in a seperate array for(int i = 0; i < 4096; i++) { blue[i] = *(texture + 0); green[i] = *(texture + 1); red[i] = *(texture + 2); trans[i] = *(texture + 3); texture += 4; } // Point the variebels in the header file to the values here b = blue; g = green; r = red; t = trans;
About 25% of the data in blue is correct (the first 25%), but after that it get more and more distorted.Code:// SSE DATA unsigned short *b; unsigned short *g; unsigned short *r; unsigned short *t;
EDIT:
This should not matter, as if I draw green as blue it works (all the data is correct no matter which screenColour channel I put it in, apart from blue) So I think it is something wrong with how I split the data, but here is the drawing code:
Code:// Create a pointer to the colours we are using unsigned short *cBlue = b; unsigned short *cGreen = g; unsigned short *cRed = r; unsigned short *cAlpha = t; for (int i = 0; i < height; i++) { for (int j = 0; j < dividedWidth; j++) { __m128i textBlue = _mm_loadu_si128( (__m128i*)cBlue); __m128i textGreen = _mm_loadu_si128( (__m128i*)cGreen); __m128i textRed = _mm_loadu_si128( (__m128i*)cRed); __m128i textAlpha = _mm_loadu_si128( (__m128i*)cAlpha); // Unions SSE_blue.m = textBlue; SSE_green.m = textGreen; SSE_red.m = textRed; // Increment colour pointer cBlue +=8; cGreen +=8; cRed +=8; cAlpha +=8; // Copy the result into the screenData pointer for(int p = 0; p < 8; p++) { *(screenDataPnt) = SSE_blue.s[p]; *(screenDataPnt + 1) = SSE_green.s[p]; *(screenDataPnt + 2) = SSE_red.s[p]; screenDataPnt += 4; } } // (ScreenWidth - textureWidth) * number of pixels screenDataPnt += 2304; }
Any ideas?



LinkBack URL
About LinkBacks



