Electry / VitaGrafix

VitaGrafix - taiHEN plugin that allows you to change resolution and FPS cap of PS Vita games
GNU General Public License v3.0
399 stars 24 forks source link

[Help] MSAA and memory modification #146

Open yeqing1990 opened 5 years ago

yeqing1990 commented 5 years ago

@Electry Can you tell me how to get rid of the game's msaa, and modify the game's memory overflow?I want to try to do more for PSV.

Electry commented 5 years ago

This highly depends on the game, and is not as straightforward as with resolution.

But, basically, for disabling MSAA you could look up sceGxmCreateRenderTarget() calls and then check SceGxmRenderTargetParams struct for multisampleMode attribute. Just backtrack until you find where the attribute is set.

typedef struct SceGxmRenderTargetParams {
    uint32_t flags;                 //!< Bitwise combined flags from ::SceGxmRenderTargetFlags.
    uint16_t width;                 //!< The width of the render target in pixels.
    uint16_t height;                //!< The height of the render target in pixels.
    uint16_t scenesPerFrame;        //!< The expected number of scenes per frame, in the range [1,SCE_GXM_MAX_SCENES_PER_RENDERTARGET].
    uint16_t multisampleMode;       //!< A value from the #SceGxmMultisampleMode enum.
    uint32_t multisampleLocations;  //!< If enabled in the flags, the multisample locations to use.
    SceUID driverMemBlock;          //!< The uncached LPDDR memblock for the render target GPU data structures or SCE_UID_INVALID_UID to specify memory should be allocated in libgxm.
} SceGxmRenderTargetParams;

typedef enum SceGxmMultisampleMode {
    SCE_GXM_MULTISAMPLE_NONE,
    SCE_GXM_MULTISAMPLE_2X,
    SCE_GXM_MULTISAMPLE_4X
} SceGxmMultisampleMode;

You could take a look at the NFSMW msaa patch.

#

Memory? Well, you need to figure out how does the game manage it. Does the game allocate one large heap block? Or perhaps separate mem blocks for each thing? (such as render targets, color/depth/stencil buffers, etc...) Is there actually no more available ram/vram? Or is the game just hardcoded to allocate specific amount which becomes insufficient? VGi could help you a tiny bit with this.

The vita provides sceKernelAllocMemBlock() function for allocating memory. If it's one large block you want to expand/shrink, find where that function is called (it takes a string as a first argument, which can be useful to locate a specific mem block sceKernelAllocMemBlock() call) and backtrack until you find the hardcoded size.

Usually though, games are smart and they allocate dynamically, so freeing up some vram is enough. The trick I do to "gain" some extra vram is shrink the parameterBufferSize (which is 16 MB by default = often unnecessary large). It's size is set during sceGxmInitialize(). So again, go to wherever it is called (in the disassembled eboot) and take a look at it's parameters.

Look at some of the patches already done. E.g. LEGO games, Ratchet & Clank or VK3 Gold are good examples. See what they do to the eboot.bin.

You can also examine the .psp2dmp of a game crash using vita-parse-core to figure out where (and possibly why) is it crashing.

vitasdk documentation is your friend.

Also, ps: excuse my shit grammar

SheidCraft commented 5 years ago

@Electry @yeqing1990 Some Ps Vita games can use more vram by cutting console functions. So in Resident Evil and Borderlans you will not be able to enter trophies, screenshots, etc. ... Perhaps you can find a way to increase memory in this way. I think not many people need trophies while playing ...

SheidCraft commented 5 years ago

@Electry @yeqing1990 If my memory serves me correctly - Minecraft began to use an increased volume of vram only with the latest patch. Perhaps if you look at the differences in the eboot.bin of the original and final versions, you will be able to find this feature.