aap / skygfx

Bringing the PS2 graphics of GTA San Andreas to PC
210 stars 18 forks source link

Use dynamic vertex buffers for increased performance #19

Open dbozan99 opened 4 years ago

dbozan99 commented 4 years ago

If you start cranking up the settings in some of the mods that change draw distances, the FPS starts dropping off dramatically and seems to be severely single-thread CPU-bottlenecked. I compiled SkyGFX with debugging symbols enabled (the .pdb file) so I could get a better look at it's performance with ETW Event Tracing. From what I can tell, the renderer spends very long periods of time locked. According to this page from MS, that seems to be what's happening here.

RW seems to offer support for Dynamic Vertex buffers with the use of RwD3D9DynamicVertexBufferCreate RwD3D9DynamicVertexBufferDestroy RwD3D9DynamicVertexBufferLock RwD3D9DynamicVertexBufferUnlock

I'd test this myself and send a Pull Request but my graphics programming knowledge is basically nonexistent so I'm not sure how to implement this correctly, or if this would even help the performance at all.

native-m commented 4 years ago

skygfx doesn't seem to touch the vertex buffer data

native-m commented 4 years ago

it might need an additional hook for GTA streaming function in order to do that

dbozan99 commented 4 years ago

Take a look at the DNInstance_PS2 function in buildingPipe.cpp. It's named vertBuffer . There's also vertexBuffer which is a pointer.