mirror of https://github.com/PCSX2/pcsx2.git
SPU2: Make sure cache hits match previous block decoded samples
Caching blocks of ADPCM is a bit sketchy because the previous samples (which it uses to generate the new ones) can change, so you can end up with blips and glitches in the sample stream, this should avoid that problem whilst not making the cache completely unusable.
This commit is contained in:
parent
97ed78109c
commit
712a922cc5
|
@ -217,7 +217,7 @@ static __forceinline s32 GetNextDataBuffered(V_Core& thiscore, uint voiceidx)
|
||||||
PcmCacheEntry& cacheLine = pcm_cache_data[cacheIdx];
|
PcmCacheEntry& cacheLine = pcm_cache_data[cacheIdx];
|
||||||
vc.SBuffer = cacheLine.Sampledata;
|
vc.SBuffer = cacheLine.Sampledata;
|
||||||
|
|
||||||
if (cacheLine.Validated)
|
if (cacheLine.Validated && vc.Prev1 == cacheLine.Prev1 && vc.Prev2 == cacheLine.Prev2)
|
||||||
{
|
{
|
||||||
// Cached block! Read from the cache directly.
|
// Cached block! Read from the cache directly.
|
||||||
// Make sure to propagate the prev1/prev2 ADPCM:
|
// Make sure to propagate the prev1/prev2 ADPCM:
|
||||||
|
@ -234,7 +234,11 @@ static __forceinline s32 GetNextDataBuffered(V_Core& thiscore, uint voiceidx)
|
||||||
{
|
{
|
||||||
// Only flag the cache if it's a non-dynamic memory range.
|
// Only flag the cache if it's a non-dynamic memory range.
|
||||||
if (vc.NextA >= SPU2_DYN_MEMLINE)
|
if (vc.NextA >= SPU2_DYN_MEMLINE)
|
||||||
|
{
|
||||||
cacheLine.Validated = true;
|
cacheLine.Validated = true;
|
||||||
|
cacheLine.Prev1 = vc.Prev1;
|
||||||
|
cacheLine.Prev2 = vc.Prev2;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsDevBuild)
|
if (IsDevBuild)
|
||||||
{
|
{
|
||||||
|
|
|
@ -598,6 +598,8 @@ struct PcmCacheEntry
|
||||||
{
|
{
|
||||||
bool Validated;
|
bool Validated;
|
||||||
s16 Sampledata[pcm_DecodedSamplesPerBlock];
|
s16 Sampledata[pcm_DecodedSamplesPerBlock];
|
||||||
|
s32 Prev1;
|
||||||
|
s32 Prev2;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern PcmCacheEntry* pcm_cache_data;
|
extern PcmCacheEntry* pcm_cache_data;
|
||||||
|
|
Loading…
Reference in New Issue