Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
General questions about PCSX2's architecture
#1
I'm trying to get a more in depth understanding of PCSX2 namely how GSdx calls OpenGL; I want to create a free flight cam extension that allows exploring 
blocked areas . The problem is, I don't really have a starting point. grep-ing around the code I found that GSWnd.cpp and GSDeviceOGL.cpp contain initializers and drawing primitives but the logic seems only to include writing frames as a whole (I may be wrong though).

Is it possible to have something like this? controlling the camera from outside the game's logic.
Reply

Sponsored links

#2
"Projection" is done on the vertex shader (files res/glsl/*tfx* )

Primitives coordinate are already on display (x,y range from 0 to w,h) coordinate
Reply
#3
(05-14-2018, 05:10 PM)gregory Wrote: "Projection" is done on the vertex shader (files res/glsl/*tfx* )

Primitives coordinate are already on display (x,y range from 0 to w,h) coordinate

So is it not possible to create a hook between the game and GSdx? By hooking I mean something like this

Is this overview of PCSX's architecture correct PS2 game --> GSdx --> OpenGL/DirectX --> os? What I want to do, is create a free fly camera extension like this.

Of course it's possible to inspect memory directly and retrieve coordinates this way but the overhead is too high on my machine.
Reply
#4
3d projection is done on VU code. Hard to hook
Reply
#5
(05-16-2018, 07:01 PM)gregory Wrote: 3d projection is done on VU code. Hard to hook

So, the architecture is: game --> VU --> host machine ?

I'm looking around VU and it looks like it doesn't have some high level viewing controls. I found code that can interact with the game in Config.h:


Code:
//------------ SPECIAL GAME FIXES!!! ---------------
#define CHECK_VUADDSUBHACK (EmuConfig.Gamefixes.VuAddSubHack) // Special Fix for Tri-ace games, they use an encryption algorithm that requires VU addi opcode to be bit-accurate.
#define CHECK_FPUCOMPAREHACK (EmuConfig.Gamefixes.FpuCompareHack) // Special Fix for Digimon Rumble Arena 2, fixes spinning/hanging on intro-menu.
#define CHECK_VUCLIPFLAGHACK (EmuConfig.Gamefixes.VuClipFlagHack) // Special Fix for Persona games, maybe others. It's to do with the VU clip flag (again).
#define CHECK_FPUMULHACK (EmuConfig.Gamefixes.FpuMulHack) // Special Fix for Tales of Destiny hangs.
#define CHECK_FPUNEGDIVHACK (EmuConfig.Gamefixes.FpuNegDivHack) // Special Fix for Gundam games messed up camera-view.
#define CHECK_XGKICKHACK (EmuConfig.Gamefixes.XgKickHack) // Special Fix for Erementar Gerad, adds more delay to VU XGkick instructions. Corrects the color of some graphics.
#define CHECK_IPUWAITHACK (EmuConfig.Gamefixes.IPUWaitHack) // Special Fix For FFX
#define CHECK_EETIMINGHACK (EmuConfig.Gamefixes.EETimingHack) // Fix all scheduled events to happen in 1 cycle.
#define CHECK_SKIPMPEGHACK (EmuConfig.Gamefixes.SkipMPEGHack) // Finds sceMpegIsEnd pattern to tell the game the mpeg is finished (Katamari and a lot of games need this)
#define CHECK_OPHFLAGHACK (EmuConfig.Gamefixes.OPHFlagHack) // Bleach Blade Battlers
#define CHECK_DMABUSYHACK (EmuConfig.Gamefixes.DMABusyHack)    // Denies writes to the DMAC when it's busy. This is correct behaviour but bad timing can cause problems.
#define CHECK_VIFFIFOHACK (EmuConfig.Gamefixes.VIFFIFOHack)    // Pretends to fill the non-existant VIF FIFO Buffer.
#define CHECK_VIF1STALLHACK (EmuConfig.Gamefixes.VIF1StallHack)  // Like above, processes FIFO data before the stall is allowed (to make sure data goes over).
#define CHECK_GIFFIFOHACK (EmuConfig.Gamefixes.GIFFIFOHack) // Enabled the GIF FIFO (more correct but slower)
#define CHECK_FMVINSOFTWAREHACK (EmuConfig.Gamefixes.FMVinSoftwareHack) // Toggle in and out of software rendering when an FMV runs.

How where these determined? The no clip flag is the same for a number of PS2 games (as suggested in the comment), implying a specific memory layout depending on game type. Is this documented anywhere? 

Looking through VU code, it seems that it translates ps2 machine code into x86 mnemonics calling at some point OpenGL. Are these only frames that VU passes to OpenGL(in that OpenGL has no control over the objects in these frames)?
Reply
#6
As gregory says, the 3D pipeline of any typical PS2 game is spread over multiple processors / coprocessors.
GSdx only deals with the GS, which is a fast rasterizer with effects, but the scene setup all happens on the EE + VUs (mostly VU1).
VU microcode is custom to each game, and it would be pretty difficult to HLE it, which I suppose would be required for external manipulation.

If you're willing to compromise / specialize on one game or engine, then something could maybe be done ;p

Edit:
Take a look at this article: https://govanify.com/post/im-path-three-ps2/
PCSX2 low level emulates everything up until the rendering stage in the GS.
Reply
#7
(05-16-2018, 08:45 PM)rama Wrote: As gregory says, the 3D pipeline of any typical PS2 game is spread over multiple processors / coprocessors.
GSdx only deals with the GS, which is a fast rasterizer with effects, but the scene setup all happens on the EE + VUs (mostly VU1).
VU microcode is custom to each game, and it would be pretty difficult to HLE it, which I suppose would be required for external manipulation.

If you're willing to compromise / specialize on one game or engine, then something could maybe be done ;p

Edit:
Take a look at this article: https://govanify.com/post/im-path-three-ps2/
PCSX2 low level emulates everything up until the rendering stage in the GS.

Then I guess it's back to cheat engine and running the game from PCSX2. I have an issue with PCSX2 in that it runs, very slowly regardless of build. The game (densha de go) aborts upon loading. The specs are:


Code:
Intel(R) Core(TM) i7-6700HQ 2.60 - 2.59 GHz
24 GB RAM
Nvidia GTX 960m

Is this enough to run any game? I read the article and am still thinking about how scheduling is done across those processors in PCSX2.
Reply
#8
Can you post the emulog of the game you're having trouble with?
Reply
#9
(05-17-2018, 10:51 PM)CK1 Wrote: Can you post the emulog of the game you're having trouble with?

emuLog.txt (other logs are empty):


Code:
PCSX2 1.5.0-0 - compiled on May 17 2018
Savestate version: 0x9a0d0000

Host Machine Init:
Operating System =  Microsoft Windows 10 Pro (build 16299), 64-bit
Physical RAM     =  24439 MB
CPU name         =  Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
Vendor/Model     =  GenuineIntel (stepping 03)
CPU speed        =  2.590 ghz (8 logical threads)
x86PType         =  Standard OEM
x86Flags         =  bfebfbff 7ffafbbf
x86EFlags        =  2c100000

x86 Features Detected:
SSE2.. SSE3.. SSSE3.. SSE4.1.. SSE4.2.. AVX.. AVX2.. FMA

Reserving memory for recompilers...

Loading plugins from D:\Projects\pcsx2\bin\plugins...
Bound   GS: GSdx32-SSE2-dbg.dll [GSdx 0 (MSVC 19.11 SSE2/AVX) 1.1.0]
Bound  PAD: LilyPad-dbg.dll [LilyPad Debug (0) 0.12.1]
Bound SPU2: Spu2-X-dbg.dll [SPU2-X-Debug 2.0.0]
Bound CDVD: cdvdGigaherz-dbg.dll [cdvdGigaherz Debug 0 0.11.0]
Bound  USB: USBnull-dbg.dll [USBnull Driver 0 0.7.0]
Bound   FW: FWnull-dbg.dll [FWnull Driver 0 0.7.0]
Bound DEV9: DEV9ghzdrk-dbg.dll [GiGaHeRz's DEV9 Driver(debug) 0.4.0]
Plugins loaded successfully.

(GameDB) 9510 games on record (loaded in 222ms)
HLE Notice: ELF does not have a path.

Initializing plugins...
Init GS
Init PAD
Init SPU2
Init CDVD
Init USB
Init FW
Init DEV9
Plugins initialized successfully.

Patches: No CRC found, using 00000000 instead.
Opening plugins...
Opening GS
Opening PAD
Opening SPU2
Opening CDVD
isoFile open ok: D:\Projects\Densha_De_Go_FINAL_JPN\slpm_65590.iso
Image type  = DVD
* CDVD Disk Open: DVD, Single layer or unknown:
* * Track 1: Data (Mode 1) (1739264 sectors)
Opening USB
Opening FW
Opening DEV9
McdSlot 0 [File]: D:\Projects\pcsx2\bin\memcards\Mcd001.ps2
McdSlot 1 [File]: D:\Projects\pcsx2\bin\memcards\Mcd002.ps2
Plugins opened successfully.
EE/iR5900-32 Recompiler Reset
Bios Found: Japan   v02.00(14/06/2004)  Console
BIOS rom1 module not found, skipping...
BIOS rom2 module not found, skipping...
BIOS erom module not found, skipping...
# Initialize memory (rev:3.70, ctm:196Mhz, cpuclk:147Mhz detected)

PlayStation 2 ======== Hard reset boot
ROMGEN=2004-0614, IOP info (CPUID=1f, CACH_CONFIG=0, 2MB, IOP mode)
<20040614-100905,ROMconf,PS20200JC20040614.bin:11696>
# Total accessable memory size: 32 MB (B:2:8:0) (370:2:7c30)
# TLB spad=0 kernel=1:12 default=13:30 extended=31:38
# Initialize Start.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize User Memory ...
# Initialize Scratch Pad ...
# Initialize Done.

EE DECI2 Manager version 0.06 Feb  6 2003 08:38:48
 CPUID=2e20, BoardID=0, ROMGEN=2004-0614, 32M

Patches: No CRC found, using 00000000 instead.
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
found 0 symbols
ELF (cdrom0:\SLPM_655.90;1) Game CRC = 0xF93AB3D0, EntryPoint = 0x00100008
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC

IOP Realtime Kernel Ver.0.9.1
   Copyright 1999 (C) Sony Computer Entertainment Inc.
Reboot service module.(99/11/10)
cdvd driver module version 0.1.1 (C)SCEI
Load File service.(99/11/05)
Multi Threaded Fileio module.(99/11/15)
iop heap service (99/11/03)
loadelf: fname rom0:OSDSYS secname all
loadelf version 3.30
Input ELF format filename = rom0:OSDSYS
0 00100000 000586dc ......
Loaded, rom0:OSDSYS
start address 0x100008
gp address 00000000
# Restart Without Memory Clear.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize Scratch Pad ...
# Restart Without Memory Clear Done.
# Restart Without Memory Clear.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize Scratch Pad ...
# Restart Without Memory Clear Done.
Get Reboot Request From EE
ROM directory not found

PlayStation 2 ======== Update rebooting..
ROM directory not found

PlayStation 2 ======== Update reboot complete
cdvdman Init
rmreset start
rmreset end
clearspu: completed
Pad Driver for OSD (2000/12/05 18:05) 392, 128

IOP Realtime Kernel Ver.0.9.1
   Copyright 1999 (C) Sony Computer Entertainment Inc.
Reboot service module.(99/11/10)
cdvd driver module version 0.1.1 (C)SCEI
Load File service.(99/11/05)
Multi Threaded Fileio module.(99/11/15)
iop heap service (99/11/03)
read/write allocate memory 4000
open name rom0:OSDVER flag 1 data 4a978
open fd = 2
open name rom0:ROMVER flag 1 data 4a978
open fd = 2
open name rom0:XDEV9 flag 1 data 4a978
open fd = 2
loadmodule: fname rom0:XDEV9 args 0 arg
dev9: unknown dev9 hardware.
loadmodule: id 32, ret 1
loadmodule: fname rom0:XDEV9SERV args 0 arg
loadmodule: id -200, ret 1
open name rom0:FONTM flag 1 data 4a978
open fd = 2
open name rom0:FNTIMAGE flag 1 data 4a978
open fd = 2
open name rom0:SNDIMAGE flag 1 data 4a978
open fd = 2
open name rom0:TEXIMAGE flag 1 data 4a978
open fd = 2
open name rom0:ICOIMAGE flag 1 data 4a978
open fd = 2
open name rom0:TZLIST flag 1 data 4a978
open fd = 2
_spu_rev_offsetaddr 1f9021
### addr = 1034255  size = 28640
_spu_rev_offsetaddr 1d9021
### addr = 968719  size = 28640
open name rom0:ROMVER flag 1 data 4a978
open fd = 2
get val add 3c0 type 2 ret 1ff000
get val add 1ff000 type 2 ret 0
open name rom0:PS1ID flag 1 data 4a978
open fd = 2
open name rom0:PS1VERJ flag 1 data 4a978
open fd = 2
open name rom1:DVDID flag 1 data 4a978
open fd = -6
(UpdateVSyncRate) Mode Changed to DVD NTSC.
(UpdateVSyncRate) FPS Limit Changed : 59.94 fps
ExecutePs2GameDisk
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
open name cdrom0:¥SYSTEM.CNF;1 flag 4 data 4a978
open fd = 2
# Restart.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize User Memory ...
# Initialize Scratch Pad ...
# Restart Done.
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
Get Reboot Request From EE
ROM directory not found

PlayStation 2 ======== Update rebooting..

PlayStation 2 ======== Update reboot complete
cdvdman Init

IOP Realtime Kernel Ver.0.9.1
   Copyright 1999 (C) Sony Computer Entertainment Inc.
Reboot service module.(99/11/10)
cdvd driver module version 0.1.1 (C)SCEI
Load File service.(99/11/05)
Multi Threaded Fileio module.(99/11/15)
iop heap service (99/11/03)
loadelf: fname rom0:PS2LOGO secname all
loadelf version 3.30
Input ELF format filename = rom0:PS2LOGO
0 01000000 00019bf0 ..
Loaded, rom0:PS2LOGO
start address 0x1000008
gp address 00000000
# Restart Without Memory Clear.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize Scratch Pad ...
# Restart Without Memory Clear Done.
# Restart Without Memory Clear.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize Scratch Pad ...
# Restart Without Memory Clear Done.
read/write allocate memory 4000
open name rom0:ROMVER flag 1 data 44078
open fd = 2
loadmodule: fname rom0:OSDSND args 0 arg
loadmodule: id 25, ret 0
_spu_rev_offsetaddr 1dfff1
### addr = 2097120  size = 32
_spu_rev_offsetaddr 1f9021
### addr = 1034255  size = 28640
(UpdateVSyncRate) Mode Changed to NTSC.
# Restart.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize User Memory ...
# Initialize Scratch Pad ...
# Restart Done.
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
Get Reboot Request From EE
ROM directory not found

PlayStation 2 ======== Update rebooting..

PlayStation 2 ======== Update reboot complete
cdvdman Init

IOP Realtime Kernel Ver.0.9.1
   Copyright 1999 (C) Sony Computer Entertainment Inc.
Reboot service module.(99/11/10)
cdvd driver module version 0.1.1 (C)SCEI
Load File service.(99/11/05)
Multi Threaded Fileio module.(99/11/15)
iop heap service (99/11/03)
loadelf: fname cdrom0:¥SLPM_655.90;1 secname all
loadelf version 3.30
(SYSTEM.CNF) Detected PS2 Disc = cdrom0:\SLPM_655.90;1
(SYSTEM.CNF) Software version = 1.02
(SYSTEM.CNF) Disc region type = NTSC
Input ELF format filename = cdrom0:¥SLPM_655.90;1
0 00100000 001c1180 .............................
Loaded, cdrom0:¥SLPM_655.90;1
start address 0x100008
gp address 00000000
# Restart Without Memory Clear.
# Initialize GS ...
# Initialize INTC ...
# Initialize TIMER ...
# Initialize DMAC ...
# Initialize VU1 ...
# Initialize VIF1 ...
# Initialize GIF ...
# Initialize VU0 ...
# Initialize VIF0 ...
# Initialize IPU ...
# Initialize FPU ...
# Initialize Scratch Pad ...
# Restart Without Memory Clear Done.
Elf entry point @ 0x00100008 about to get recompiled. Load patches first.
Get Reboot Request From EE
ROM directory not found

PlayStation 2 ======== Update rebooting..

PlayStation 2 ======== Update reboot complete
cdvdman Init

IOP Realtime Kernel Ver. 2.2
   Copyright 1999-2002 (C) Sony Computer Entertainment Inc.
Reboot service module.(99/11/10)
cdvd driver module version 0.1.1 (C)SCEI
Load File service.(99/11/05)
Multi Threaded Fileio module.(99/11/15)
iop heap service (99/11/03)
loadmodule: fname cdrom0:¥MODULE¥SIO2MAN.IRX;1 args 0 arg
loadmodule: id 25, ret 0
loadmodule: fname cdrom0:¥MODULE¥SIO2D.IRX;1 args 0 arg
loadmodule: id 26, ret 0
loadmodule: fname cdrom0:¥MODULE¥DBCMAN.IRX;1 args 0 arg
loadmodule: id 27, ret 0
loadmodule: fname cdrom0:¥MODULE¥PADMAN.IRX;1 args 0 arg
loadmodule: id 28, ret 0
loadmodule: fname cdrom0:¥MODULE¥LIBSD.IRX;1 args 0 arg
loadmodule: id 29, ret 0
loadmodule: fname cdrom0:¥MODULE¥SDRDRV.IRX;1 args 0 arg
SDR driver version 4.0.1 (C) SCEI
Exit rsd_main
loadmodule: id 30, ret 0
loadmodule: fname cdrom0:¥MODULE¥CDVDSTM.IRX;1 args 0 arg
loadmodule: id 31, ret 2
loadmodule: fname cdrom0:¥MODULE¥BGMMAN.IRX;1 args 0 arg
BGM+FILE Manager version 1.4.4 (C)TAITO (Sep  4 2003)
loadmodule: id 32, ret 0
loadmodule: fname cdrom0:¥MODULE¥USBD.IRX;1 args 0 arg
USB Driver (Version 1.1.0)
loadmodule: id 33, ret 2
loadmodule: fname cdrom0:¥MODULE¥USBDENCO.IRX;1 args 0 arg
loadmodule: id 34, ret 0
loadmodule: fname cdrom0:¥MODULE¥USBSHINC.IRX;1 args 0 arg
usbshinc.c:151:UsbShin Start
loadmodule: id 35, ret 0
loadmodule: fname cdrom0:¥MODULE¥USBRJCON.IRX;1 args 0 arg
loadmodule: id 36, ret 0
loadmodule: fname cdrom0:¥MODULE¥MC2_S1.IRX;1 args 0 arg
loadmodule: id 37, ret 2
Stream Buffer 1Bank 32768byte 5banks 163840byte used
Stream Buffer 1Bank 32768byte 5banks 163840byte used
> Selected savestate slot 1
> Selected savestate slot 2

[Image: zwzzu5Y.png]
Reply
#10
Debug plugins will impact performance, build the release/devel plugins and run those on a debug exe if you wish. Alternatively, you can grab a dev build from buildbot.orphis.net/pcsx2

Also, if you manage to fix the game/it remains broken; you can add your test results here Smile
https://forums.pcsx2.net/Thread-Densha-d...SLPM-65590
Reply




Users browsing this thread: 1 Guest(s)