From f60aef2e16e67fcc9b130e7dc6ab5ee63a297884 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 17 Jan 2016 12:43:13 -0800 Subject: [PATCH] Add a more specific interface for video frames. Since we know more about them. No functional change yet. --- Core/HLE/sceMpeg.cpp | 7 ++++--- Core/HLE/scePsmf.cpp | 2 +- GPU/Directx9/GPU_DX9.cpp | 4 ++++ GPU/Directx9/GPU_DX9.h | 1 + GPU/GLES/GLES_GPU.cpp | 4 ++++ GPU/GLES/GLES_GPU.h | 1 + GPU/GPUInterface.h | 1 + GPU/Null/NullGpu.cpp | 4 ++++ GPU/Null/NullGpu.h | 1 + GPU/Software/SoftGpu.cpp | 5 +++++ GPU/Software/SoftGpu.h | 1 + 11 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Core/HLE/sceMpeg.cpp b/Core/HLE/sceMpeg.cpp index 6e4495c06e..a66c648ce8 100644 --- a/Core/HLE/sceMpeg.cpp +++ b/Core/HLE/sceMpeg.cpp @@ -1094,7 +1094,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr // playing all pmp_queue frames ctx->mediaengine->m_pFrameRGB = pmp_queue.front(); int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode); - gpu->InvalidateCache(buffer, bufferSize, GPU_INVALIDATE_SAFE); + gpu->NotifyVideoUpload(buffer, bufferSize, frameWidth, ctx->videoPixelMode); ctx->avc.avcFrameStatus = 1; ctx->videoFrameCount++; @@ -1105,7 +1105,7 @@ static u32 sceMpegAvcDecode(u32 mpeg, u32 auAddr, u32 frameWidth, u32 bufferAddr } else if(ctx->mediaengine->stepVideo(ctx->videoPixelMode)) { int bufferSize = ctx->mediaengine->writeVideoImage(buffer, frameWidth, ctx->videoPixelMode); - gpu->InvalidateCache(buffer, bufferSize, GPU_INVALIDATE_SAFE); + gpu->NotifyVideoUpload(buffer, bufferSize, frameWidth, ctx->videoPixelMode); ctx->avc.avcFrameStatus = 1; ctx->videoFrameCount++; } else { @@ -1872,7 +1872,8 @@ static u32 sceMpegAvcCsc(u32 mpeg, u32 sourceAddr, u32 rangeAddr, int frameWidth int height = Memory::Read_U32(rangeAddr + 12); int destSize = ctx->mediaengine->writeVideoImageWithRange(destAddr, frameWidth, ctx->videoPixelMode, x, y, width, height); - gpu->InvalidateCache(destAddr, destSize, GPU_INVALIDATE_SAFE); + gpu->NotifyVideoUpload(destAddr, destSize, frameWidth, ctx->videoPixelMode); + // Do not use avcDecodeDelayMs 's value // Will cause video 's screen dislocation in Bleach heat of soul 6 // https://github.com/hrydgard/ppsspp/issues/5535 diff --git a/Core/HLE/scePsmf.cpp b/Core/HLE/scePsmf.cpp index 97ccfae66f..64c15ebfa7 100644 --- a/Core/HLE/scePsmf.cpp +++ b/Core/HLE/scePsmf.cpp @@ -1540,7 +1540,7 @@ static int scePsmfPlayerGetVideoData(u32 psmfPlayer, u32 videoDataAddr) int bufw = videoData->frameWidth == 0 ? 512 : videoData->frameWidth & ~1; // Always write the video frame, even after the video has ended. int displaybufSize = psmfplayer->mediaengine->writeVideoImage(videoData->displaybuf, bufw, videoPixelMode); - gpu->InvalidateCache(videoData->displaybuf, displaybufSize, GPU_INVALIDATE_SAFE); + gpu->NotifyVideoUpload(videoData->displaybuf, displaybufSize, bufw, videoPixelMode); __PsmfUpdatePts(psmfplayer, videoData); _PsmfPlayerFillRingbuffer(psmfplayer); diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 6995992fff..ad74afb9f2 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -1952,6 +1952,10 @@ void DIRECTX9_GPU::InvalidateCacheInternal(u32 addr, int size, GPUInvalidationTy } } +void DIRECTX9_GPU::NotifyVideoUpload(u32 addr, int size, int width, int format) { + InvalidateCache(addr, size, GPU_INVALIDATE_SAFE); +} + void DIRECTX9_GPU::PerformMemoryCopyInternal(u32 dest, u32 src, int size) { if (!framebufferManager_.NotifyFramebufferCopy(src, dest, size, false, gstate_c.skipDrawReason)) { // We use a little hack for Download/Upload using a VRAM mirror. diff --git a/GPU/Directx9/GPU_DX9.h b/GPU/Directx9/GPU_DX9.h index a36add8c2c..9fe8e31fa3 100644 --- a/GPU/Directx9/GPU_DX9.h +++ b/GPU/Directx9/GPU_DX9.h @@ -48,6 +48,7 @@ public: void BeginFrame() override; void UpdateStats() override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; + void NotifyVideoUpload(u32 addr, int size, int width, int format) override; bool PerformMemoryCopy(u32 dest, u32 src, int size) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override; diff --git a/GPU/GLES/GLES_GPU.cpp b/GPU/GLES/GLES_GPU.cpp index 22bd84ae7e..ab6853331b 100644 --- a/GPU/GLES/GLES_GPU.cpp +++ b/GPU/GLES/GLES_GPU.cpp @@ -2201,6 +2201,10 @@ void GLES_GPU::InvalidateCacheInternal(u32 addr, int size, GPUInvalidationType t } } +void GLES_GPU::NotifyVideoUpload(u32 addr, int size, int width, int format) { + InvalidateCache(addr, size, GPU_INVALIDATE_SAFE); +} + void GLES_GPU::PerformMemoryCopyInternal(u32 dest, u32 src, int size) { if (!framebufferManager_.NotifyFramebufferCopy(src, dest, size, false, gstate_c.skipDrawReason)) { // We use a little hack for Download/Upload using a VRAM mirror. diff --git a/GPU/GLES/GLES_GPU.h b/GPU/GLES/GLES_GPU.h index 5ad5719902..e1bdc76ffe 100644 --- a/GPU/GLES/GLES_GPU.h +++ b/GPU/GLES/GLES_GPU.h @@ -52,6 +52,7 @@ public: void BeginFrame() override; void UpdateStats() override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; + void NotifyVideoUpload(u32 addr, int size, int width, int format) override; bool PerformMemoryCopy(u32 dest, u32 src, int size) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 5cd115300c..5255972175 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -253,6 +253,7 @@ public: // Invalidate any cached content sourced from the specified range. // If size = -1, invalidate everything. virtual void InvalidateCache(u32 addr, int size, GPUInvalidationType type) = 0; + virtual void NotifyVideoUpload(u32 addr, int size, int width, int format) = 0; // Update either RAM from VRAM, or VRAM from RAM... or even VRAM from VRAM. virtual bool PerformMemoryCopy(u32 dest, u32 src, int size) = 0; virtual bool PerformMemorySet(u32 dest, u8 v, int size) = 0; diff --git a/GPU/Null/NullGpu.cpp b/GPU/Null/NullGpu.cpp index 9f6b881163..4e67b381d4 100644 --- a/GPU/Null/NullGpu.cpp +++ b/GPU/Null/NullGpu.cpp @@ -687,6 +687,10 @@ void NullGPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) { // Nothing to invalidate. } +void NullGPU::NotifyVideoUpload(u32 addr, int size, int width, int format) { + // Nothing to do. +} + bool NullGPU::PerformMemoryCopy(u32 dest, u32 src, int size) { // Nothing to update. InvalidateCache(dest, size, GPU_INVALIDATE_HINT); diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index db6f9000ed..7918054673 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -34,6 +34,7 @@ public: void CopyDisplayToOutput() override {} void UpdateStats() override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; + void NotifyVideoUpload(u32 addr, int size, int width, int format) override; bool PerformMemoryCopy(u32 dest, u32 src, int size) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index ad96fce331..7e9d48158c 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -873,6 +873,11 @@ void SoftGPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) // Nothing to invalidate. } +void SoftGPU::NotifyVideoUpload(u32 addr, int size, int width, int format) +{ + // Ignore. +} + bool SoftGPU::PerformMemoryCopy(u32 dest, u32 src, int size) { // Nothing to update. diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 8cdd67ed69..e06e664c92 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -58,6 +58,7 @@ public: void CopyDisplayToOutput() override; void UpdateStats() override; void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override; + void NotifyVideoUpload(u32 addr, int size, int width, int format) override; bool PerformMemoryCopy(u32 dest, u32 src, int size) override; bool PerformMemorySet(u32 dest, u8 v, int size) override; bool PerformMemoryDownload(u32 dest, int size) override;