SSE MOVUPS/128bit Memcpy + Fixed Doublebuffer

This commit is contained in:
Kieron Morris 2022-01-29 01:39:45 +00:00
parent 19b433a19f
commit a3217de71a
3 changed files with 33 additions and 14 deletions

View File

@ -22,7 +22,7 @@ unit doublebuffer;
interface interface
uses uses
lmemorymanager, tracer, videotypes; lmemorymanager, tracer, videotypes, serial, util;
//Init the driver, and register with the video interface in a state ready for execution. //Init the driver, and register with the video interface in a state ready for execution.
procedure init(Register : FRegisterDriver); procedure init(Register : FRegisterDriver);
@ -54,21 +54,28 @@ end;
procedure Flush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer); procedure Flush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer);
var var
X,Y : uint32; idx : uint32;
Back,Front : PuInt64; Back,Front : PuInt64;
BufferSize : uint32;
const
COPY_WIDTH = 64;
begin begin
tracer.push_trace('doublebuffer.Flush.enter'); //tracer.push_trace('doublebuffer.Flush.enter');
if not(BackBuffer^.Initialized) then exit; if not(BackBuffer^.Initialized) then exit;
if ((FrontBuffer^.Width > BackBuffer^.Width) or (FrontBuffer^.Height > BackBuffer^.Height)) then exit; if ((FrontBuffer^.Width > BackBuffer^.Width) or (FrontBuffer^.Height > BackBuffer^.Height)) then exit;
Back:= PUint64(BackBuffer^.Location); Back:= PUint64(BackBuffer^.Location);
Front:= PuInt64(FrontBuffer^.Location); Front:= PuInt64(FrontBuffer^.Location);
for X:=0 to (BackBuffer^.Width-1) div 2 do begin BufferSize:= ( ( BackBuffer^.Width * BackBuffer^.Height * BackBuffer^.BitsPerPixel) div COPY_WIDTH ) - 1;
for Y:=0 to (BackBuffer^.Height-1) div 2 do begin for idx:=0 to BufferSize do begin
Front[(Y * BackBuffer^.Width) + X]:= Back[(Y * BackBuffer^.Width) + X]; 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);
end; end;
end; //tracer.push_trace('doublebuffer.Flush.exit');
tracer.push_trace('doublebuffer.Flush.exit');
end; end;
function enable(VideoInterface : PVideoInterface) : boolean; function enable(VideoInterface : PVideoInterface) : boolean;

View File

@ -51,19 +51,22 @@ end;
Procedure basicFFlush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer); Procedure basicFFlush(FrontBuffer : PVideoBuffer; BackBuffer : PVideoBuffer);
var var
x, y : uint32; idx : uint32;
Back,Front : puint32; Back,Front : puint32;
BufferSize : uint32;
const
COPY_WIDTH = 32;
begin begin
tracer.push_trace('video.basicFFlush.enter'); //tracer.push_trace('video.basicFFlush.enter');
If not(FrontBuffer^.Initialized and BackBuffer^.Initialized) then exit; If not(FrontBuffer^.Initialized and BackBuffer^.Initialized) then exit;
if (BackBuffer^.Width > FrontBuffer^.Width) or (BackBuffer^.Height > FrontBuffer^.Height) then exit; if (BackBuffer^.Width > FrontBuffer^.Width) or (BackBuffer^.Height > FrontBuffer^.Height) then exit;
Back:= puint32(BackBuffer^.Location); Back:= puint32(BackBuffer^.Location);
Front:= puint32(FrontBuffer^.Location); Front:= puint32(FrontBuffer^.Location);
for x:=0 to BackBuffer^.Width-1 do begin BufferSize:= ( (BackBuffer^.Width * BackBuffer^.Height * BackBuffer^.BitsPerPixel ) div COPY_WIDTH ) - 1;
for y:=0 to BackBuffer^.Height-1 do begin for idx:=0 to BufferSize do begin
Front[(Y * BackBuffer^.Width) + X]:= Back[(Y * BackBuffer^.Width) + X]; Front[idx]:= Back[idx];
end;
end; end;
end; end;

View File

@ -49,6 +49,7 @@ procedure io_wait;
procedure memset(location : uint32; value : uint8; size : uint32); procedure memset(location : uint32; value : uint8; size : uint32);
procedure memcpy(source : uint32; dest : uint32; size : uint32); procedure memcpy(source : uint32; dest : uint32; size : uint32);
procedure __SSE_128_memcpy(source : uint32; dest : uint32);
procedure printmemory(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean); procedure printmemory(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean);
procedure printmemoryWND(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean; WND : HWND); procedure printmemoryWND(source : uint32; length : uint32; col : uint32; delim : PChar; offset_row : boolean; WND : HWND);
@ -127,6 +128,14 @@ begin
div6432:= (r0 SHL 32) OR r4; div6432:= (r0 SHL 32) OR r4;
end; end;
procedure __SSE_128_memcpy(source : uint32; dest : uint32); assembler;
asm
MOV EAX, Source
MOV ECX, Dest
MOVUPS XMM0, [EAX]
MOVUPS [ECX], XMM0
end;
function switchendian16(b : uint16) : uint16; function switchendian16(b : uint16) : uint16;
begin begin
switchendian16:= ((b AND $FF00) SHR 8) OR ((b AND $00FF) SHL 8); switchendian16:= ((b AND $FF00) SHR 8) OR ((b AND $00FF) SHL 8);