Double Buffer with SSE 128 copy working
This commit is contained in:
		| @@ -55,25 +55,24 @@ end; | ||||
| procedure Flush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer); | ||||
| var | ||||
|     idx : uint32; | ||||
|     Back,Front : PuInt64; | ||||
|     Back,Front : uint32; | ||||
|     BufferSize : uint32; | ||||
|  | ||||
| const | ||||
|     COPY_WIDTH = 64; | ||||
|     //COPY_WIDTH = 64; //Use this for 64bit copies | ||||
|     COPY_WIDTH = 128; //Use this for SSE copies | ||||
|  | ||||
| begin | ||||
|     //tracer.push_trace('doublebuffer.Flush.enter'); | ||||
|     if not(BackBuffer^.Initialized) then exit; | ||||
|     if ((FrontBuffer^.Width > BackBuffer^.Width) or (FrontBuffer^.Height > BackBuffer^.Height)) then exit; | ||||
|     Back:= PUint64(BackBuffer^.Location); | ||||
|     Front:= PuInt64(FrontBuffer^.Location); | ||||
|     Back:= BackBuffer^.Location; | ||||
|     Front:= FrontBuffer^.Location; | ||||
|     BufferSize:= ( ( BackBuffer^.Width * BackBuffer^.Height * BackBuffer^.BitsPerPixel) div COPY_WIDTH ) - 1; | ||||
|     for idx:=0 to BufferSize do begin | ||||
|         Front[idx]:= Back[idx]; | ||||
|         //Front[idx]:= Back[idx]; | ||||
|         // -- TODO: Get SSE working here for 128bit copies -- | ||||
|         // __SSE_128_memcpy(uint32(Front), uint32(Back)); | ||||
|         // Front:= PUint64(uint32(Front) + 16); | ||||
|         // Back:= PUint64(uint32(Back) + 16);      | ||||
|         __SSE_128_memcpy(Back + (idx * 16), Front + (idx * 16));   | ||||
|     end; | ||||
|     //tracer.push_trace('doublebuffer.Flush.exit'); | ||||
| end; | ||||
|   | ||||
| @@ -131,9 +131,9 @@ end; | ||||
| procedure __SSE_128_memcpy(source : uint32; dest : uint32); assembler; | ||||
| asm | ||||
|     MOV EAX, Source | ||||
|     MOV ECX, Dest | ||||
|     MOVUPS XMM0, [EAX] | ||||
|     MOVUPS [ECX], XMM0 | ||||
|     MOVAPS XMM1, [EAX] | ||||
|     MOV EAX, Dest | ||||
|     MOVAPS [EAX], XMM1 | ||||
| end; | ||||
|  | ||||
| function switchendian16(b : uint16) : uint16; | ||||
|   | ||||
| @@ -127,6 +127,9 @@ var | ||||
|  | ||||
|    colour          : TRGB32; | ||||
|  | ||||
|    array1          : Array[0..255] of char; | ||||
|    array2          : Array[0..255] of char; | ||||
|     | ||||
| begin | ||||
|      { Init the base system unit } | ||||
|      System.init(); | ||||
| @@ -213,6 +216,32 @@ begin | ||||
|      video.enable('BASIC_DOUBLE_BUFFER'); | ||||
|      colour:= color.white; | ||||
|  | ||||
|     //  serial.sendHex(uint32(@array1[8])); | ||||
|     //  serial.sendHex(uint32(@array2[8])); | ||||
|     //  for i:=8 to 23 do begin | ||||
|     //     array2[i]:= '?'; | ||||
|     //  end; | ||||
|     //  array2[24]:= #0; | ||||
|  | ||||
|     //  array1[8]:= 'H'; | ||||
|     //  array1[9]:= 'e'; | ||||
|     //  array1[10]:= 'l'; | ||||
|     //  array1[11]:= 'l'; | ||||
|     //  array1[12]:= 'o'; | ||||
|     //  array1[13]:= 'w'; | ||||
|     //  array1[14]:= 'o'; | ||||
|     //  array1[15]:= 'r'; | ||||
|     //  array1[16]:= 'l'; | ||||
|     //  array1[17]:= 'd'; | ||||
|     //  array1[18]:= '1'; | ||||
|     //  array1[19]:= '2'; | ||||
|     //  array1[20]:= '3'; | ||||
|     //  array1[21]:= '4'; | ||||
|     //  array1[22]:= '5'; | ||||
|     //  array1[23]:= '!'; | ||||
|     //  __SSE_128_memcpy(uint32(@array1[8]), uint32(@array2[8])); | ||||
|     //  serial.sendString(pchar(@array2[8])); | ||||
|  | ||||
|      for i:=0 to video.frontBufferWidth-1 do begin | ||||
|         for z:=0 to video.frontBufferHeight-1 do begin | ||||
|             video.DrawPixel(i, z, colour); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user