From febdf7fe13b1778b98a17d61602f04e9effaf103 Mon Sep 17 00:00:00 2001 From: Pavel <68122101+red-prig@users.noreply.github.com> Date: Wed, 19 Oct 2022 11:38:17 +0300 Subject: [PATCH] + --- kernel/ps4_pthread.pas | 14 ++++---- ps4_program.pas | 55 ++++++++++++++++++------------- src/ps4_libscepad.pas | 61 ++++++++++++++++++++++++++++++++--- vulkan/vHostBufferManager.pas | 8 ++++- vulkan/vMemory.pas | 2 +- 5 files changed, 103 insertions(+), 37 deletions(-) diff --git a/kernel/ps4_pthread.pas b/kernel/ps4_pthread.pas index bfeb5deb..24693b90 100644 --- a/kernel/ps4_pthread.pas +++ b/kernel/ps4_pthread.pas @@ -447,11 +447,11 @@ begin StackBottom:=StackTop-StackLength; - Writeln('StackTop :',HexStr(StackTop)); - Writeln('Sptr :',HexStr(Sptr)); - - Writeln('StackBottom:',HexStr(StackBottom)); - Writeln('StackLength:',HexStr(StackLength,16)); + //Writeln('StackTop :',HexStr(StackTop)); + //Writeln('Sptr :',HexStr(Sptr)); + // + //Writeln('StackBottom:',HexStr(StackBottom)); + //Writeln('StackLength:',HexStr(StackLength,16)); ReadBarrier; if (data<>nil) and (data^.entry<>nil) then @@ -952,7 +952,7 @@ procedure ps4___pthread_cleanup_push_imp(routine:t_cb_proc; var curthread:pthread; begin - Writeln('__pthread_cleanup_push_imp'); + //Writeln('__pthread_cleanup_push_imp'); curthread:=_get_curthread; if (curthread=nil) then Exit; @@ -970,7 +970,7 @@ var curthread:pthread; old:p_pthread_cleanup; begin - Writeln('__pthread_cleanup_pop_imp'); + //Writeln('__pthread_cleanup_pop_imp'); curthread:=_get_curthread; if (curthread=nil) then Exit; diff --git a/ps4_program.pas b/ps4_program.pas index 63c74a52..1d0511b1 100644 --- a/ps4_program.pas +++ b/ps4_program.pas @@ -1287,6 +1287,29 @@ begin end; end; +Function sce_load_filter(Const name:RawByteString):Boolean; +const + c_libc='libc'; + c_libSce='libSce'; +begin + Result:=(Copy(name,1,Length(c_libc))=c_libc) or + (Copy(name,1,Length(c_libSce))=c_libSce); +end; + +function TryLoadElf(Const path,name:RawByteString):TElf_node; +var + s:RawByteString; +begin + //bulid path + s:=IncludeTrailingPathDelimiter(path)+'sce_module'+DirectorySeparator+name; + Result:=LoadPs4ElfFromFile(s); //try defaut .prx + if (Result=nil) then + begin + s:=ChangeFileExt(s,'.sprx'); + Result:=LoadPs4ElfFromFile(s); //try .sprx + end; +end; + function Tps4_program.Loader(Const name:RawByteString):TElf_node; var nid:QWORD; @@ -1313,34 +1336,20 @@ begin Exit; end; - Result:=LoadPs4ElfFromFile(IncludeTrailingPathDelimiter(app_path)+'sce_module'+DirectorySeparator+name); - if (Result<>nil) then //is default load app_path\sce_module + if sce_load_filter(name) then begin - Result.Prepare; - ps4_app.RegistredElf(Result); - Exit; + Result:=TryLoadElf(app_path,name); + if (Result<>nil) then //is default load app_path\sce_module + begin + Result.Prepare; + ps4_app.RegistredElf(Result); + Exit; + end; end; // - //Result:=LoadPs4ElfFromFile(IncludeTrailingPathDelimiter(app_path)+'Media'+DirectorySeparator+'Modules'+DirectorySeparator+name); - //if (Result<>nil) then //is app_path\Media\Modules - //begin - // Result.Prepare; - // ps4_app.RegistredElf(Result); - // Exit; - //end; - // - //Result:=LoadPs4ElfFromFile(IncludeTrailingPathDelimiter(app_path)+'Media'+DirectorySeparator+'Plugins'+DirectorySeparator+name); - //if (Result<>nil) then //is app_path\Media\Plugins - //begin - // Result.Prepare; - // ps4_app.RegistredElf(Result); - // Exit; - //end; - // - - Result:=LoadPs4ElfFromFile(IncludeTrailingPathDelimiter(GetCurrentDir)+'sce_module'+DirectorySeparator+name); + Result:=TryLoadElf(GetCurrentDir,name); if (Result<>nil) then //is default load current_dir\sce_module begin Result.Prepare; diff --git a/src/ps4_libscepad.pas b/src/ps4_libscepad.pas index ee2412ba..d099b54b 100644 --- a/src/ps4_libscepad.pas +++ b/src/ps4_libscepad.pas @@ -341,7 +341,7 @@ type connectionType:Byte; connectedCount:Byte; connected:Boolean; - deviceClass:DWORD; + deviceClass:DWORD; //ScePadDeviceClass reserve:array[0..7] of Byte; end; @@ -351,6 +351,7 @@ const SCE_PAD_CONNECTION_TYPE_REMOTE_VITA=SCE_PAD_CONNECTION_TYPE_REMOTE; SCE_PAD_CONNECTION_TYPE_REMOTE_DUALSHOCK4=2; + //ScePadDeviceClass SCE_PAD_DEVICE_CLASS_INVALID = -1; SCE_PAD_DEVICE_CLASS_STANDARD = 0; SCE_PAD_DEVICE_CLASS_GUITAR = 1; @@ -363,11 +364,10 @@ const SCE_PAD_DEVICE_CLASS_FLIGHT_STICK = 8; SCE_PAD_DEVICE_CLASS_GUN = 9; - -function ps4_scePadGetControllerInformation(handle:Integer;pInfo:PScePadControllerInformation):Integer; SysV_ABI_CDecl; +function ps4_scePadGetControllerInformation(handle:Integer; + pInfo:PScePadControllerInformation + ):Integer; SysV_ABI_CDecl; begin - //FillChar(pInfo^,SizeOf(ScePadControllerInformation),1); - //Exit(0); if (pInfo=nil) then Exit(SCE_PAD_ERROR_INVALID_ARG); pInfo^:=Default(ScePadControllerInformation); pInfo^.touchPadInfo.pixelDensity := 1; @@ -382,6 +382,56 @@ begin Result:=0; end; +type + pScePadDeviceClassExtendedInformation=^ScePadDeviceClassExtendedInformation; + ScePadDeviceClassExtendedInformation=packed record + deviceClass:DWORD; //ScePadDeviceClass + reserved:DWORD; + classData:packed record + Case Byte of + + 0:(steeringWheel:packed record + capability:Byte; + reserved1:Byte; + maxPhysicalWheelAngle:Word; + reserved2:QWORD; + end); + + 1:(guitar:packed record + capability:Byte; + quantityOfSelectorSwitch:Byte; + reserved1:Word; + reserved2:QWORD; + end); + + 2:(drum:packed record + capability:Byte; + reserved1:Byte; + reserved2:Word; + reserved3:QWORD; + end); + + 3:(flightStick:packed record + capability:Byte; + reserved1:Byte; + reserved2:Word; + reserved3:QWORD; + end); + + 4:(data:array[0..11] of Byte); + + end; + end; + +function ps4_scePadDeviceClassGetExtendedInformation(handle:Integer; + pExtInfo:pScePadDeviceClassExtendedInformation + ):Integer; SysV_ABI_CDecl; +begin + if (pExtInfo=nil) then Exit(SCE_PAD_ERROR_INVALID_ARG); + pExtInfo^:=Default(ScePadDeviceClassExtendedInformation); + pExtInfo^.deviceClass:=SCE_PAD_DEVICE_CLASS_STANDARD; +end; + function ps4_scePadSetMotionSensorState(handle:Integer;bEnable:Boolean):Integer; SysV_ABI_CDecl; begin Result:=0; @@ -419,6 +469,7 @@ begin lib^.set_proc($C8556739D1B1BD96,@ps4_scePadSetVibration); lib^.set_proc($0EC703D62F475F5C,@ps4_scePadResetLightBar); lib^.set_proc($8233FDFCA433A149,@ps4_scePadGetControllerInformation); + lib^.set_proc($01CB25A4DD631D1F,@ps4_scePadDeviceClassGetExtendedInformation); lib^.set_proc($72556F2F86439EDC,@ps4_scePadSetMotionSensorState); lib^.set_proc($451E27A2F50410D6,@ps4_scePadSetLightBar); lib^.set_proc($AC866747A792A6F9,@ps4_scePadResetOrientation); diff --git a/vulkan/vHostBufferManager.pas b/vulkan/vHostBufferManager.pas index baaad9be..c2ab7126 100644 --- a/vulkan/vHostBufferManager.pas +++ b/vulkan/vHostBufferManager.pas @@ -212,7 +212,11 @@ begin t.Foffset:=delta; t.FSparse:=Binds; - VkBindSparseBufferMemory(queue,t.FHandle,Length(Binds),@Binds[0]); + if (VkBindSparseBufferMemory(queue,t.FHandle,Length(Binds),@Binds[0])<>VK_SUCCESS) then + begin + t.Free; + Exit; + end; Result:=t; end; @@ -251,11 +255,13 @@ begin Case _is_sparce(Addr,Size,usage) of 0:begin t:=_New_simple(Addr,Size,usage); + Assert(t<>nil,'create simple buffer fail'); end; 1:begin //is Sparse buffers Assert(vDevice.sparseBinding,'sparseBinding not support'); Assert(MemManager.SparceSupportHost,'sparse not support for host'); t:=_New_sparce(cmd.FQueue.FHandle,Addr,Size,usage); + Assert(t<>nil,'create sparse buffer fail'); end; else; end; diff --git a/vulkan/vMemory.pas b/vulkan/vMemory.pas index 4094a084..325e4725 100644 --- a/vulkan/vMemory.pas +++ b/vulkan/vMemory.pas @@ -248,7 +248,7 @@ end; function TvMemManager.SparceSupportHost:Boolean; begin - Result:=(FHostVisibMt and FSparceMemoryTypes)<>0; + Result:=((1 shl FHostVisibMt) and FSparceMemoryTypes)<>0; end; function TvMemManager.findMemoryType(Filter:TVkUInt32;prop:TVkMemoryPropertyFlags):Integer;