From d143734fb7d80a61d5d680889feae0654b0a30e8 Mon Sep 17 00:00:00 2001 From: red-prig Date: Sat, 9 Jul 2022 23:22:16 +0300 Subject: [PATCH] + --- chip/pm4defs.pas | 1 + chip/ps4_videodrv.pas | 12 +++++++++++- ps4_libscegnmdriver.pas | 30 ++++++++++++++++++++++++++++-- spirv/SprvEmit.pas | 2 +- spirv/emit_post_op.pas | 13 +++++++++++++ spirv/srInput.pas | 4 ++++ vulkan/vImageTiling.pas | 16 +++++++++++++--- 7 files changed, 71 insertions(+), 7 deletions(-) diff --git a/chip/pm4defs.pas b/chip/pm4defs.pas index 91b4f45e..6bc862c1 100644 --- a/chip/pm4defs.pas +++ b/chip/pm4defs.pas @@ -141,6 +141,7 @@ const OP_HINT_BASE_ALLOCATE_FROM_COMMAND_BUFFER =$68750000; OP_HINT_PUSH_MARKER =$68750001; OP_HINT_POP_MARKER =$68750002; + OP_HINT_SET_MARKER =$68750003; OP_HINT_SET_VSHARP_IN_USER_DATA =$68750004; OP_HINT_SET_TSHARP_IN_USER_DATA =$68750005; OP_HINT_SET_SSHARP_IN_USER_DATA =$68750006; diff --git a/chip/ps4_videodrv.pas b/chip/ps4_videodrv.pas index 63130097..6fd3cca7 100644 --- a/chip/ps4_videodrv.pas +++ b/chip/ps4_videodrv.pas @@ -959,6 +959,11 @@ begin {$ifdef ww}Writeln('\HINT_PUSH_MARKER:',Body);{$endif} end; +procedure onSetMarker(Body:PChar); +begin + {$ifdef ww}Writeln('\HINT_SET_MARKER:',Body);{$endif} +end; + procedure onWidthHeight(Body:PWORD); begin {$ifdef ww}Writeln('\HINT_',Body[0],'_',Body[1]);{$endif} @@ -1010,10 +1015,14 @@ begin OP_HINT_WRITE_GPU_PREFETCH_INTO_L2 :Writeln('\HINT_WRITE_GPU_PREFETCH_INTO_L2'); OP_HINT_BASE_ALLOCATE_FROM_COMMAND_BUFFER :Writeln('\HINT_BASE_ALLOCATE_FROM_COMMAND_BUFFER'); - OP_HINT_PUSH_MARKER ://Writeln('\HINT_PUSH_MARKER'); + OP_HINT_PUSH_MARKER : onPushMarker(@Body[1]); OP_HINT_POP_MARKER :Writeln('\HINT_POP_MARKER'); + + OP_HINT_SET_MARKER: + onSetMarker(@Body[1]); + OP_HINT_SET_VSHARP_IN_USER_DATA :Writeln('\HINT_SET_VSHARP_IN_USER_DATA'); OP_HINT_SET_TSHARP_IN_USER_DATA :Writeln('\HINT_SET_TSHARP_IN_USER_DATA'); OP_HINT_SET_SSHARP_IN_USER_DATA :Writeln('\HINT_SET_SSHARP_IN_USER_DATA'); @@ -2209,6 +2218,7 @@ begin fdump_cs:=DumpCS(GPU_REGS); GFXRing.AllocCmdBuffer; + GFXRing.CmdBuffer.EndRenderPass; FCSShader:=FetchShader(vShaderStageCs,0,GPU_REGS); if (FCSShader=nil) then Exit; diff --git a/ps4_libscegnmdriver.pas b/ps4_libscegnmdriver.pas index a2489753..4e36abfb 100644 --- a/ps4_libscegnmdriver.pas +++ b/ps4_libscegnmdriver.pas @@ -522,19 +522,21 @@ function ps4_sceGnmInsertPushMarker(cmdBuffer:PDWORD;numDwords:DWORD;param:PChar var cmdSize,len,len3,len4:DWORD; begin + if (cmdBuffer=nil) or (param=nil) then Exit(-1); + len:=StrLen(param); len3:=(len + $c) shr 3; len4:=(len + $8) shr 2; cmdSize:=len4+len3*2; - Assert(cmdSize+2=numDwords); + if ((cmdSize+2)<>numDwords) then Exit(-1); cmdBuffer[0]:=cmdSize*$10000 or $c0001000; //NOP cmdBuffer[1]:=$68750001; len3:=len+1; Move(param^,cmdBuffer[2],len3); - FillChar(PByte(@cmdBuffer[2])[len3],numDwords*SizeOf(DWORD)-len3,0); + FillChar(PByte(@cmdBuffer[2])[len3],cmdSize*SizeOf(DWORD)-len3,0); Result:=0; end; @@ -551,6 +553,29 @@ begin Result:=0; end; +function ps4_sceGnmInsertSetMarker(cmdBuffer:PDWORD;numDwords:DWORD;param:PChar):Integer; SysV_ABI_CDecl; +var + cmdSize,len,len3,len4:DWORD; +begin + if (cmdBuffer=nil) or (param=nil) then Exit(-1); + + len:=StrLen(param); + len3:=(len + $c) shr 3; + len4:=(len + $8) shr 2; + + cmdSize:=len4+len3*2; + if ((cmdSize+2)<>numDwords) then Exit(-1); + + cmdBuffer[0]:=cmdSize*$10000 or $c0001000; //NOP + cmdBuffer[1]:=$68750003; + + len3:=len+1; + Move(param^,cmdBuffer[2],len3); + FillChar(PByte(@cmdBuffer[2])[len3],cmdSize*SizeOf(DWORD)-len3,0); + + Result:=0; +end; + // called in waitUntilSafeForRendering function ps4_sceGnmInsertWaitFlipDone(cmdBuffer:PDWORD;numDwords:DWORD;videoOutHandle,displayBufferIndex:Integer):Integer; SysV_ABI_CDecl; var @@ -1477,6 +1502,7 @@ begin lib^.set_proc($5B512D8FF8E55BB6,@ps4_sceGnmInsertPushMarker); lib^.set_proc($EEA65536012EF926,@ps4_sceGnmInsertPopMarker); + lib^.set_proc($8E222DCD2EBEDB68,@ps4_sceGnmInsertSetMarker); lib^.set_proc($D6A5CB1C8A5138F1,@ps4_sceGnmInsertWaitFlipDone); lib^.set_proc($29796D9C2C042474,@ps4_sceGnmSetCsShader); diff --git a/spirv/SprvEmit.pas b/spirv/SprvEmit.pas index a53ca51d..4937bba5 100644 --- a/spirv/SprvEmit.pas +++ b/spirv/SprvEmit.pas @@ -1210,7 +1210,7 @@ begin if (ENA.FRONT_FACE_ENA<>0) then begin - AddInput(@FRegsStory.VGRP[p],dtUint32,itFrontFace); + AddInput(@FRegsStory.VGRP[p],dtBool,itFrontFace); p:=p+1; end; diff --git a/spirv/emit_post_op.pas b/spirv/emit_post_op.pas index 66fef86a..0895873c 100644 --- a/spirv/emit_post_op.pas +++ b/spirv/emit_post_op.pas @@ -1480,6 +1480,15 @@ var Inc(Result); end; + procedure _SetReg(src:PsrRegNode); + begin + src^.mark_read; + dst^.pWriter.SetParam(ntReg,src); + node^.OpId:=OpLinks; //mark remove + node^.dst:=Default(TOpParamSingle); + Inc(Result); + end; + begin Result:=0; dst:=node^.dst.AsReg; @@ -1494,6 +1503,10 @@ begin data:=F_WQM_32(data); _SetConst(dst^.dtype,data); end else + if (src^.dtype=dtBool) then + begin + _SetReg(src); + end else begin Assert(false,'TODO') end; diff --git a/spirv/srInput.pas b/spirv/srInput.pas index c17c5082..50e473aa 100644 --- a/spirv/srInput.pas +++ b/spirv/srInput.pas @@ -170,6 +170,10 @@ begin begin Decorates^.emit_decorate(ntVar,pVar,Decoration.BuiltIn,BuiltIn.VertexIndex); end; + itFrontFace: + begin + Decorates^.emit_decorate(ntVar,pVar,Decoration.BuiltIn,BuiltIn.FrontFacing); + end; else Assert(false,'AllocBinding'); end; diff --git a/vulkan/vImageTiling.pas b/vulkan/vImageTiling.pas index bd1623e2..f8c5cc03 100644 --- a/vulkan/vImageTiling.pas +++ b/vulkan/vImageTiling.pas @@ -189,14 +189,24 @@ end; Procedure _Copy_Linear(cmd:TvCustomCmdBuffer;buf:TvTempBuffer;image:TvImage2); var BufferImageCopy:TVkBufferImageCopy; + extend:TvExtent3D; size:Ptruint; begin cmd.AddDependence(@buf.Release); - size:=image.key.params.extend.width* - image.key.params.extend.height* - image.key.params.extend.depth* + extend:=image.key.params.extend; + + if IsTexelFormat(image.key.cformat) then + begin + extend.width :=(extend.width +3) div 4; + extend.height :=(extend.height +3) div 4; + extend.depth :=(extend.depth +3) div 4; + end; + + size:=extend.width* + extend.height* + extend.depth* getFormatSize(image.key.cformat); image.PushBarrier(cmd,