This is neccessary as some games specify fetching that goes
past the end of the buffer, even though they do not use this
data. This causes the host-GPU to discard the triangle but
we need to still render it.
We need to store the registers before using them, or else
parameter calling order could cause the write to occur
prior to the read as we do not hook directly into asmjit.
This commit includes a complete rewrite of the expanded heap
implementation to match closer with the native implementation.
Additionally, some refactoring was applied to the other heaps
to match with the pattern used for the new expanded heap.
This is required as some games stupidly expect that the memory
in their MEM2 bucket is zerod out when the application starts
up. When the loader runs and uses MEM2 for its loader temp
region, this "dirties" that memory, causing those games to fail.
We can't use the system heap as it is not large enough for some
games temporary data (seen up to 0x02900000 bytes). Note that
we do not keep the loader memory mapped at all times, only when
the loader is actively running.
The previous code assumed that VAO's specified their divisor info
on a per-attribute basis when it is actually per-buffer. We now
track the divisor information for each buffer and set it once at
the end, we also track to ensure that all attributes of a single
buffer use the same divisor information.
This is not entirely neccessary. However, when threads are
rescheduled through an interrupt, it is hard to guarentee
that the threads stack pointer is at an acceptable place.
This will make it even less likely that our scheduler
corrupts the state of any running threads.
This bug would cause the emulator to freeze up when trying to
shut down. This was due to a race between the shutdown flag
and the notification to tell the FS thread that it was set.
GX2Invalidate can be called from any core at any time. This is
contrary to the idea that only one core can write at a time.
It is possible that more of our internal commands should do this.