mirror of https://github.com/red-prig/fpPS4.git
This commit is contained in:
parent
8d87f57637
commit
4a4c8d0760
|
@ -16,14 +16,15 @@ uses
|
||||||
type
|
type
|
||||||
p_attr=^t_attr;
|
p_attr=^t_attr;
|
||||||
t_attr=packed record
|
t_attr=packed record
|
||||||
init :QWORD;
|
init :DWORD;
|
||||||
|
index:DWORD;
|
||||||
attr :t_register_buffer_attr;
|
attr :t_register_buffer_attr;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
p_buffer=^t_buffer;
|
p_buffer=^t_buffer;
|
||||||
t_buffer=packed record
|
t_buffer=packed record
|
||||||
init :QWORD;
|
init :DWORD;
|
||||||
attr :QWORD;
|
attr :DWORD;
|
||||||
left :Pointer; //buffer ptr
|
left :Pointer; //buffer ptr
|
||||||
right:Pointer; //Stereo ptr
|
right:Pointer; //Stereo ptr
|
||||||
left_dmem :Pointer; //buffer ptr
|
left_dmem :Pointer; //buffer ptr
|
||||||
|
@ -86,6 +87,8 @@ type
|
||||||
|
|
||||||
Fflip_count:array[0..15] of Integer;
|
Fflip_count:array[0..15] of Integer;
|
||||||
|
|
||||||
|
FPrevBufIndex:Integer;
|
||||||
|
|
||||||
Fsubmit_count:array[0..15] of PRTLEvent;
|
Fsubmit_count:array[0..15] of PRTLEvent;
|
||||||
|
|
||||||
flip_rate:Integer;
|
flip_rate:Integer;
|
||||||
|
@ -94,7 +97,7 @@ type
|
||||||
m_attr:array[0.. 3] of t_attr;
|
m_attr:array[0.. 3] of t_attr;
|
||||||
m_bufs:array[0..15] of t_buffer;
|
m_bufs:array[0..15] of t_buffer;
|
||||||
|
|
||||||
m_sbat:array[0.. 3] of t_attr;
|
m_sbat:t_attr;
|
||||||
|
|
||||||
dst_cache:Pointer;
|
dst_cache:Pointer;
|
||||||
|
|
||||||
|
@ -108,7 +111,8 @@ type
|
||||||
function UnregisterBufferAttribute(attrid:Byte):Integer; override;
|
function UnregisterBufferAttribute(attrid:Byte):Integer; override;
|
||||||
function RegisterBuffer (buf:p_register_buffer):Integer; override;
|
function RegisterBuffer (buf:p_register_buffer):Integer; override;
|
||||||
function UnregisterBuffer (index:Integer):Integer; override;
|
function UnregisterBuffer (index:Integer):Integer; override;
|
||||||
procedure SubmitNode (Node:PQNodeSubmit;is_eop:Boolean);
|
procedure SubmitNode (Node:PQNodeSubmit);
|
||||||
|
procedure SetBuffer (bufferIndex:Integer;is_eop:Boolean);
|
||||||
procedure ResetBuffer (bufferIndex:Integer);
|
procedure ResetBuffer (bufferIndex:Integer);
|
||||||
procedure HackPreWait (submit:p_submit_flip);
|
procedure HackPreWait (submit:p_submit_flip);
|
||||||
function SubmitFlip (submit:p_submit_flip):Integer; override;
|
function SubmitFlip (submit:p_submit_flip):Integer; override;
|
||||||
|
@ -199,6 +203,8 @@ var
|
||||||
begin
|
begin
|
||||||
Result:=inherited;
|
Result:=inherited;
|
||||||
|
|
||||||
|
FPrevBufIndex:=-1;
|
||||||
|
|
||||||
Writeln('OpenMainWindows->');
|
Writeln('OpenMainWindows->');
|
||||||
|
|
||||||
hWindow:=p_host_ipc.OpenMainWindows();
|
hWindow:=p_host_ipc.OpenMainWindows();
|
||||||
|
@ -262,18 +268,21 @@ function TDisplayHandleSoft.RegisterBufferAttribute(attrid:Byte;attr:p_register_
|
||||||
begin
|
begin
|
||||||
if (m_attr[attrid].init<>0) then Exit(EINVAL);
|
if (m_attr[attrid].init<>0) then Exit(EINVAL);
|
||||||
|
|
||||||
m_attr[attrid].init:=1;
|
m_attr[attrid].init :=1;
|
||||||
m_attr[attrid].attr:=attr^;
|
m_attr[attrid].index:=attrid;
|
||||||
|
m_attr[attrid].attr :=attr^;
|
||||||
|
|
||||||
Result:=0;
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TDisplayHandleSoft.SubmitBufferAttribute(attrid:Byte;attr:p_register_buffer_attr):Integer;
|
function TDisplayHandleSoft.SubmitBufferAttribute(attrid:Byte;attr:p_register_buffer_attr):Integer;
|
||||||
begin
|
begin
|
||||||
if (m_sbat[attrid].init<>0) then Exit(EBUSY);
|
if (m_attr[attrid].init=0) then Exit(EINVAL);
|
||||||
|
if (m_sbat.init<>0) then Exit(EBUSY);
|
||||||
|
|
||||||
m_sbat[attrid].attr:=attr^;
|
m_sbat.attr :=attr^;
|
||||||
m_sbat[attrid].init:=1;
|
m_sbat.index:=attrid;
|
||||||
|
System.InterlockedExchange(m_sbat.init,1);
|
||||||
|
|
||||||
Result:=0;
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
@ -281,6 +290,7 @@ end;
|
||||||
function TDisplayHandleSoft.UnregisterBufferAttribute(attrid:Byte):Integer;
|
function TDisplayHandleSoft.UnregisterBufferAttribute(attrid:Byte):Integer;
|
||||||
begin
|
begin
|
||||||
if (m_attr[attrid].init=0) then Exit(EINVAL);
|
if (m_attr[attrid].init=0) then Exit(EINVAL);
|
||||||
|
if (m_sbat.init<>0) and (m_sbat.index=attrid) then Exit(EBUSY);
|
||||||
|
|
||||||
m_attr[attrid].init:=0;
|
m_attr[attrid].init:=0;
|
||||||
|
|
||||||
|
@ -345,7 +355,8 @@ end;
|
||||||
|
|
||||||
function TDisplayHandleSoft.UnregisterBuffer(index:Integer):Integer;
|
function TDisplayHandleSoft.UnregisterBuffer(index:Integer):Integer;
|
||||||
begin
|
begin
|
||||||
if (m_bufs[index].init=0) then Exit(EINVAL);
|
if (m_bufs[index].init=0) then Exit(EINVAL);
|
||||||
|
if (Fflip_count[index]<>0) then Exit(EBUSY);
|
||||||
|
|
||||||
m_bufs[index].init:=0;
|
m_bufs[index].init:=0;
|
||||||
|
|
||||||
|
@ -924,33 +935,10 @@ begin
|
||||||
ReleaseDC(hWindow, hdc);
|
ReleaseDC(hWindow, hdc);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDisplayHandleSoft.SubmitNode(Node:PQNodeSubmit;is_eop:Boolean);
|
procedure TDisplayHandleSoft.SubmitNode(Node:PQNodeSubmit);
|
||||||
var
|
|
||||||
//prev:Integer;
|
|
||||||
bufferIndex:Integer;
|
|
||||||
begin
|
begin
|
||||||
bufferIndex:=Node^.submit.bufferIndex;
|
|
||||||
|
|
||||||
Node^.tsc:=rdtsc();
|
Node^.tsc:=rdtsc();
|
||||||
|
|
||||||
//set label
|
|
||||||
if (bufferIndex<>-1) then
|
|
||||||
begin
|
|
||||||
//prev:=labels[bufferIndex];
|
|
||||||
|
|
||||||
labels[bufferIndex]:=1;
|
|
||||||
|
|
||||||
//Writeln('[SubmitNode] labels[',bufferIndex,']=',prev,'->',labels[bufferIndex],' *',Fflip_count[bufferIndex]);
|
|
||||||
|
|
||||||
//
|
|
||||||
System.InterlockedIncrement(Fflip_count[bufferIndex]);
|
|
||||||
//
|
|
||||||
if not is_eop then
|
|
||||||
begin
|
|
||||||
System.InterlockedIncrement(last_status.flipPendingNum0);
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FSubmitQueue.Push(Node);
|
FSubmitQueue.Push(Node);
|
||||||
|
|
||||||
if (Node^.submit.flipMode=SCE_VIDEO_OUT_FLIP_MODE_HSYNC) then
|
if (Node^.submit.flipMode=SCE_VIDEO_OUT_FLIP_MODE_HSYNC) then
|
||||||
|
@ -961,29 +949,47 @@ end;
|
||||||
|
|
||||||
procedure gc_wakeup_internal_ptr(ptr:Pointer); register; external;
|
procedure gc_wakeup_internal_ptr(ptr:Pointer); register; external;
|
||||||
|
|
||||||
procedure TDisplayHandleSoft.ResetBuffer(bufferIndex:Integer);
|
procedure TDisplayHandleSoft.SetBuffer(bufferIndex:Integer;is_eop:Boolean);
|
||||||
//var
|
|
||||||
// prev:Integer;
|
|
||||||
begin
|
begin
|
||||||
|
//set buf label
|
||||||
//reset label
|
|
||||||
if (bufferIndex<>-1) then
|
if (bufferIndex<>-1) then
|
||||||
begin
|
begin
|
||||||
System.InterlockedDecrement(last_status.flipPendingNum0);
|
labels[bufferIndex]:=1;
|
||||||
|
gc_wakeup_internal_ptr(@labels[bufferIndex]);
|
||||||
|
//
|
||||||
|
System.InterlockedIncrement(Fflip_count[bufferIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
//prev:=labels[bufferIndex];
|
//inc pending frame
|
||||||
|
System.InterlockedIncrement(last_status.flipPendingNum0);
|
||||||
|
|
||||||
if (System.InterlockedDecrement(Fflip_count[bufferIndex])=0) then
|
//inc GPU pending frame
|
||||||
begin
|
if is_eop then
|
||||||
labels[bufferIndex]:=0;
|
begin
|
||||||
gc_wakeup_internal_ptr(@labels[bufferIndex]);
|
System.InterlockedIncrement(last_status.gcQueueNum);
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
//Writeln('[ResetBuffer] labels[',bufferIndex,']=',prev,'->',labels[bufferIndex],' *',Fflip_count[bufferIndex]);
|
procedure TDisplayHandleSoft.ResetBuffer(bufferIndex:Integer);
|
||||||
|
begin
|
||||||
|
System.InterlockedDecrement(last_status.flipPendingNum0);
|
||||||
|
|
||||||
|
//dec flip counter
|
||||||
|
if (bufferIndex<>-1) then
|
||||||
|
begin
|
||||||
|
System.InterlockedDecrement(Fflip_count[bufferIndex]);
|
||||||
|
end;
|
||||||
|
|
||||||
|
//reset prev label
|
||||||
|
if (FPrevBufIndex<>-1) then
|
||||||
|
begin
|
||||||
|
labels[FPrevBufIndex]:=0;
|
||||||
|
gc_wakeup_internal_ptr(@labels[FPrevBufIndex]);
|
||||||
end;
|
end;
|
||||||
labels[16]:=0; //bufferIndex = -1 ???
|
labels[16]:=0; //bufferIndex = -1 ???
|
||||||
|
|
||||||
|
//save buffer index to next reset
|
||||||
|
FPrevBufIndex:=bufferIndex;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -1029,7 +1035,9 @@ begin
|
||||||
|
|
||||||
HackPreWait(submit);
|
HackPreWait(submit);
|
||||||
|
|
||||||
SubmitNode(Node,False);
|
SetBuffer(submit^.bufferIndex,False);
|
||||||
|
|
||||||
|
SubmitNode(Node);
|
||||||
|
|
||||||
Result:=0;
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
@ -1072,12 +1080,7 @@ begin
|
||||||
Flip^.submit :=Node;
|
Flip^.submit :=Node;
|
||||||
Flip^.submit_id:=submit_id;
|
Flip^.submit_id:=submit_id;
|
||||||
|
|
||||||
System.InterlockedIncrement(last_status.gcQueueNum);
|
SetBuffer(submit^.bufferIndex,True);
|
||||||
|
|
||||||
if (submit^.bufferIndex<>-1) then
|
|
||||||
begin
|
|
||||||
System.InterlockedIncrement(last_status.flipPendingNum0);
|
|
||||||
end;
|
|
||||||
|
|
||||||
STAILQ_INSERT_TAIL(@FFlipQueue,Flip,@Flip^.entry);
|
STAILQ_INSERT_TAIL(@FFlipQueue,Flip,@Flip^.entry);
|
||||||
|
|
||||||
|
@ -1103,17 +1106,17 @@ begin
|
||||||
|
|
||||||
Node:=Flip^.submit;
|
Node:=Flip^.submit;
|
||||||
|
|
||||||
Flip^.submit :=nil;
|
Flip^.submit:=nil;
|
||||||
Flip^.submit_id:=0;
|
|
||||||
FFlipAlloc.Free(Flip);
|
FFlipAlloc.Free(Flip);
|
||||||
|
|
||||||
|
//dec GPU pending mark
|
||||||
System.InterlockedDecrement(last_status.gcQueueNum);
|
System.InterlockedDecrement(last_status.gcQueueNum);
|
||||||
|
|
||||||
mtx_unlock(dce_mtx^);
|
mtx_unlock(dce_mtx^);
|
||||||
|
|
||||||
if (Node<>nil) then
|
if (Node<>nil) then
|
||||||
begin
|
begin
|
||||||
SubmitNode(Node,True);
|
SubmitNode(Node);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Exit;
|
Exit;
|
||||||
|
@ -1154,17 +1157,15 @@ var
|
||||||
attr:p_attr;
|
attr:p_attr;
|
||||||
begin
|
begin
|
||||||
//submit attr
|
//submit attr
|
||||||
For i:=0 to High(m_sbat) do
|
if (m_sbat.init<>0) then
|
||||||
if (m_sbat[i].init<>0) then
|
|
||||||
begin
|
begin
|
||||||
|
i:=m_sbat.index;
|
||||||
|
//
|
||||||
mtx_lock(dce_mtx^);
|
mtx_lock(dce_mtx^);
|
||||||
|
m_attr[i].attr:=m_sbat.attr;
|
||||||
m_attr[i].init:=1;
|
|
||||||
m_attr[i].attr:=m_sbat[i].attr;
|
|
||||||
|
|
||||||
m_sbat[i].init:=0;
|
|
||||||
|
|
||||||
mtx_unlock(dce_mtx^);
|
mtx_unlock(dce_mtx^);
|
||||||
|
//
|
||||||
|
m_sbat.init:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
submit:=@Node^.submit;
|
submit:=@Node^.submit;
|
||||||
|
|
Loading…
Reference in New Issue