Get rid of GPUCommon's "Internal" functions.

This commit is contained in:
Henrik Rydgård 2017-11-05 20:33:28 +01:00
parent bb68906d88
commit 8c69be9bfa
12 changed files with 59 additions and 123 deletions

View File

@ -286,7 +286,7 @@ void GPU_D3D11::DeviceRestore() {
// Nothing needed.
}
void GPU_D3D11::InitClearInternal() {
void GPU_D3D11::InitClear() {
bool useNonBufferedRendering = g_Config.iRenderingMode == FB_NON_BUFFERED_MODE;
if (useNonBufferedRendering) {
// device_->Clear(0, NULL, D3DCLEAR_STENCIL | D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.f, 0);
@ -305,8 +305,8 @@ void GPU_D3D11::BeginHostFrame() {
}
}
void GPU_D3D11::ReapplyGfxStateInternal() {
GPUCommon::ReapplyGfxStateInternal();
void GPU_D3D11::ReapplyGfxState() {
GPUCommon::ReapplyGfxState();
// TODO: Dirty our caches for depth states etc
}
@ -316,8 +316,8 @@ void GPU_D3D11::EndHostFrame() {
draw_->BindPipeline(nullptr);
}
void GPU_D3D11::BeginFrameInternal() {
GPUCommon::BeginFrameInternal();
void GPU_D3D11::BeginFrame() {
GPUCommon::BeginFrame();
textureCacheD3D11_->StartFrame();
drawEngine_.BeginFrame();
@ -357,7 +357,7 @@ bool GPU_D3D11::FramebufferReallyDirty() {
return true;
}
void GPU_D3D11::CopyDisplayToOutputInternal() {
void GPU_D3D11::CopyDisplayToOutput() {
float blendColor[4]{};
context_->OMSetBlendState(stockD3D11.blendStateDisabledWithColorMask[0xF], blendColor, 0xFFFFFFFF);

View File

@ -40,7 +40,7 @@ public:
void PreExecuteOp(u32 op, u32 diff) override;
void ExecuteOp(u32 op, u32 diff) override;
void ReapplyGfxStateInternal() override;
void ReapplyGfxState() override;
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void GetStats(char *buffer, size_t bufsize) override;
void ClearCacheNextFrame() override;
@ -96,9 +96,9 @@ private:
void CheckFlushOp(int cmd, u32 diff);
void BuildReportingInfo();
void InitClearInternal() override;
void BeginFrameInternal() override;
void CopyDisplayToOutputInternal() override;
void InitClear() override;
void BeginFrame() override;
void CopyDisplayToOutput() override;
ID3D11Device *device_;
ID3D11DeviceContext *context_;

View File

@ -251,7 +251,7 @@ void GPU_DX9::DeviceRestore() {
// Nothing needed.
}
void GPU_DX9::InitClearInternal() {
void GPU_DX9::InitClear() {
bool useNonBufferedRendering = g_Config.iRenderingMode == FB_NON_BUFFERED_MODE;
if (useNonBufferedRendering) {
dxstate.depthWrite.set(true);
@ -272,12 +272,12 @@ void GPU_DX9::BeginHostFrame() {
}
}
void GPU_DX9::ReapplyGfxStateInternal() {
void GPU_DX9::ReapplyGfxState() {
dxstate.Restore();
GPUCommon::ReapplyGfxStateInternal();
GPUCommon::ReapplyGfxState();
}
void GPU_DX9::BeginFrameInternal() {
void GPU_DX9::BeginFrame() {
// Turn off vsync when unthrottled
int desiredVSyncInterval = g_Config.bVSync ? 1 : 0;
if ((PSP_CoreParameter().unthrottle) || (PSP_CoreParameter().fpsLimit == 1))
@ -292,7 +292,7 @@ void GPU_DX9::BeginFrameInternal() {
depalShaderCache_.Decimate();
// fragmentTestCache_.Decimate();
GPUCommon::BeginFrameInternal();
GPUCommon::BeginFrame();
shaderManagerDX9_->DirtyShader();
framebufferManager_->BeginFrame();
@ -323,7 +323,7 @@ bool GPU_DX9::FramebufferReallyDirty() {
return true;
}
void GPU_DX9::CopyDisplayToOutputInternal() {
void GPU_DX9::CopyDisplayToOutput() {
dxstate.depthWrite.set(true);
dxstate.colorMask.set(true, true, true, true);

View File

@ -41,7 +41,7 @@ public:
void PreExecuteOp(u32 op, u32 diff) override;
void ExecuteOp(u32 op, u32 diff) override;
void ReapplyGfxStateInternal() override;
void ReapplyGfxState() override;
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void GetStats(char *buffer, size_t bufsize) override;
void ClearCacheNextFrame() override;
@ -96,9 +96,9 @@ private:
void CheckFlushOp(int cmd, u32 diff);
void BuildReportingInfo();
void InitClearInternal() override;
void BeginFrameInternal() override;
void CopyDisplayToOutputInternal() override;
void InitClear() override;
void BeginFrame() override;
void CopyDisplayToOutput() override;
LPDIRECT3DDEVICE9 device_;
LPDIRECT3DDEVICE9EX deviceEx_;

View File

@ -401,13 +401,14 @@ void GPU_GLES::DeviceRestore() {
UpdateVsyncInterval(true);
}
void GPU_GLES::ReinitializeInternal() {
void GPU_GLES::Reinitialize() {
GPUCommon::Reinitialize();
textureCacheGL_->Clear(true);
depalShaderCache_.Clear();
framebufferManagerGL_->DestroyAllFBOs();
}
void GPU_GLES::InitClearInternal() {
void GPU_GLES::InitClear() {
bool useNonBufferedRendering = g_Config.iRenderingMode == FB_NON_BUFFERED_MODE;
if (useNonBufferedRendering) {
glstate.depthWrite.set(GL_TRUE);
@ -467,13 +468,13 @@ void GPU_GLES::UpdateCmdInfo() {
}
}
void GPU_GLES::ReapplyGfxStateInternal() {
void GPU_GLES::ReapplyGfxState() {
drawEngine_.RestoreVAO();
glstate.Restore();
GPUCommon::ReapplyGfxStateInternal();
GPUCommon::ReapplyGfxState();
}
void GPU_GLES::BeginFrameInternal() {
void GPU_GLES::BeginFrame() {
UpdateVsyncInterval(resized_);
resized_ = false;
@ -483,7 +484,7 @@ void GPU_GLES::BeginFrameInternal() {
depalShaderCache_.Decimate();
fragmentTestCache_.Decimate();
GPUCommon::BeginFrameInternal();
GPUCommon::BeginFrame();
// Save the cache from time to time. TODO: How often?
if (!shaderCachePath_.empty() && (gpuStats.numFlips & 1023) == 0) {
@ -523,7 +524,7 @@ bool GPU_GLES::FramebufferReallyDirty() {
return true;
}
void GPU_GLES::CopyDisplayToOutputInternal() {
void GPU_GLES::CopyDisplayToOutput() {
// Flush anything left over.
framebufferManagerGL_->RebindFramebuffer();
drawEngine_.Flush();

View File

@ -41,7 +41,7 @@ public:
void PreExecuteOp(u32 op, u32 diff) override;
void ExecuteOp(u32 op, u32 diff) override;
void ReapplyGfxStateInternal() override;
void ReapplyGfxState() override;
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void GetStats(char *buffer, size_t bufsize) override;
@ -95,10 +95,10 @@ private:
void CheckFlushOp(int cmd, u32 diff);
void BuildReportingInfo();
void InitClearInternal() override;
void BeginFrameInternal() override;
void CopyDisplayToOutputInternal() override;
void ReinitializeInternal() override;
void InitClear() override;
void BeginFrame() override;
void CopyDisplayToOutput() override;
void Reinitialize() override;
inline void UpdateVsyncInterval(bool force);
void UpdateCmdInfo();

View File

@ -381,14 +381,6 @@ void GPUCommon::EndHostFrame() {
}
void GPUCommon::InitClear() {
InitClearInternal();
}
void GPUCommon::CopyDisplayToOutput() {
CopyDisplayToOutputInternal();
}
void GPUCommon::Reinitialize() {
memset(dls, 0, sizeof(dls));
for (int i = 0; i < DisplayListMaxCount; ++i) {
@ -404,7 +396,6 @@ void GPUCommon::Reinitialize() {
timeSpentStepping_ = 0.0;
interruptsEnabled_ = true;
curTickEst_ = 0;
ReinitializeInternal();
}
int GPUCommon::EstimatePerVertexCost() {
@ -927,10 +918,6 @@ bool GPUCommon::InterpretList(DisplayList &list) {
}
void GPUCommon::BeginFrame() {
BeginFrameInternal();
}
void GPUCommon::BeginFrameInternal() {
if (dumpNextFrame_) {
NOTICE_LOG(G3D, "DUMPING THIS FRAME");
dumpThisFrame_ = true;
@ -994,10 +981,6 @@ void GPUCommon::UpdatePC(u32 currentPC, u32 newPC) {
}
void GPUCommon::ReapplyGfxState() {
ReapplyGfxStateInternal();
}
void GPUCommon::ReapplyGfxStateInternal() {
// The commands are embedded in the command memory so we can just reexecute the words. Convenient.
// To be safe we pass 0xFFFFFFFF as the diff.
@ -1037,12 +1020,7 @@ int GPUCommon::GetNextListIndex() {
}
}
bool GPUCommon::ProcessDLQueue() {
ProcessDLQueueInternal();
return true;
}
void GPUCommon::ProcessDLQueueInternal() {
void GPUCommon::ProcessDLQueue() {
startingTicks = CoreTiming::GetTicks();
cyclesExecuted = 0;
curTickEst_ = std::max(busyTicks, startingTicks + cyclesExecuted);
@ -1326,7 +1304,7 @@ void GPUCommon::Execute_End(u32 op, u32 diff) {
__GeTriggerSync(GPU_SYNC_LIST, currentList->id, currentList->waitTicks);
if (currentList->started && currentList->context.IsValid()) {
gstate.Restore(currentList->context);
ReapplyGfxStateInternal();
ReapplyGfxState();
}
}
break;
@ -2231,27 +2209,17 @@ void GPUCommon::DoBlockTransfer(u32 skipDrawReason) {
cyclesExecuted += ((height * width * bpp) * 16) / 10;
}
void GPUCommon::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.
// Since they're identical we don't need to copy.
if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) {
Memory::Memcpy(dest, src, size);
}
}
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
}
void GPUCommon::PerformMemorySetInternal(u32 dest, u8 v, int size) {
if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, true, gstate_c.skipDrawReason)) {
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
}
}
bool GPUCommon::PerformMemoryCopy(u32 dest, u32 src, int size) {
// Track stray copies of a framebuffer in RAM. MotoGP does this.
if (framebufferManager_->MayIntersectFramebuffer(src) || framebufferManager_->MayIntersectFramebuffer(dest)) {
PerformMemoryCopyInternal(dest, src, size);
if (!framebufferManager_->NotifyFramebufferCopy(src, dest, size, false, gstate_c.skipDrawReason)) {
// We use a little hack for Download/Upload using a VRAM mirror.
// Since they're identical we don't need to copy.
if (!Memory::IsVRAMAddress(dest) || (dest ^ 0x00400000) != src) {
Memory::Memcpy(dest, src, size);
}
}
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
return true;
}
@ -2264,7 +2232,9 @@ bool GPUCommon::PerformMemorySet(u32 dest, u8 v, int size) {
// This may indicate a memset, usually to 0, of a framebuffer.
if (framebufferManager_->MayIntersectFramebuffer(dest)) {
Memory::Memset(dest, v, size);
PerformMemorySetInternal(dest, v, size);
if (!framebufferManager_->NotifyFramebufferCopy(dest, dest, size, true, gstate_c.skipDrawReason)) {
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
}
return true;
}
@ -2294,10 +2264,6 @@ bool GPUCommon::PerformMemoryUpload(u32 dest, int size) {
}
void GPUCommon::InvalidateCache(u32 addr, int size, GPUInvalidationType type) {
InvalidateCacheInternal(addr, size, type);
}
void GPUCommon::InvalidateCacheInternal(u32 addr, int size, GPUInvalidationType type) {
if (size > 0)
textureCache_->Invalidate(addr, size, type);
else
@ -2322,16 +2288,12 @@ void GPUCommon::NotifyVideoUpload(u32 addr, int size, int width, int format) {
bool GPUCommon::PerformStencilUpload(u32 dest, int size) {
if (framebufferManager_->MayIntersectFramebuffer(dest)) {
PerformStencilUploadInternal(dest, size);
framebufferManager_->NotifyStencilUpload(dest, size);
return true;
}
return false;
}
void GPUCommon::PerformStencilUploadInternal(u32 dest, int size) {
framebufferManager_->NotifyStencilUpload(dest, size);
}
bool GPUCommon::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) {
u32 fb_address = type == GPU_DBG_FRAMEBUF_RENDER ? gstate.getFrameBufRawAddress() : framebufferManager_->DisplayFramebufAddr();
int fb_stride = type == GPU_DBG_FRAMEBUF_RENDER ? gstate.FrameBufStride() : framebufferManager_->DisplayFramebufStride();

View File

@ -66,7 +66,7 @@ public:
void PreExecuteOp(u32 op, u32 diff) override;
bool InterpretList(DisplayList &list) override;
virtual bool ProcessDLQueue();
void ProcessDLQueue();
u32 UpdateStall(int listid, u32 newstall) override;
u32 EnqueueList(u32 listpc, u32 stall, int subIntrBase, PSPPointer<PspGeListArgs> args, bool head) override;
u32 DequeueList(int listid) override;
@ -79,8 +79,8 @@ public:
u32 Break(int mode) override;
void ReapplyGfxState() override;
void CopyDisplayToOutput() override;
void InitClear() override;
void CopyDisplayToOutput() override = 0;
void InitClear() override = 0;
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;
@ -105,10 +105,6 @@ public:
void Execute_BoundingBox(u32 op, u32 diff);
void Execute_BlockTransferStart(u32 op, u32 diff);
void Execute_TexScaleU(u32 op, u32 diff);
void Execute_TexScaleV(u32 op, u32 diff);
void Execute_TexOffsetU(u32 op, u32 diff);
void Execute_TexOffsetV(u32 op, u32 diff);
void Execute_TexLevel(u32 op, u32 diff);
void Execute_WorldMtxNum(u32 op, u32 diff);
@ -233,11 +229,7 @@ protected:
}
}
virtual void InitClearInternal() {}
void BeginFrame() override;
virtual void BeginFrameInternal();
virtual void CopyDisplayToOutputInternal() {}
virtual void ReinitializeInternal() {}
// To avoid virtual calls to PreExecuteOp().
virtual void FastRunLoop(DisplayList &list) = 0;
@ -247,8 +239,6 @@ protected:
void PopDLQueue();
void CheckDrawSync();
int GetNextListIndex();
void ProcessDLQueueInternal();
virtual void ReapplyGfxStateInternal();
virtual void FastLoadBoneMatrix(u32 target);
// TODO: Unify this.
@ -265,11 +255,6 @@ protected:
}
}
void PerformMemoryCopyInternal(u32 dest, u32 src, int size);
void PerformMemorySetInternal(u32 dest, u8 v, int size);
void PerformStencilUploadInternal(u32 dest, int size);
void InvalidateCacheInternal(u32 addr, int size, GPUInvalidationType type);
FramebufferManagerCommon *framebufferManager_;
TextureCacheCommon *textureCache_;
DrawEngineCommon *drawEngineCommon_;

View File

@ -281,13 +281,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) {
draw_->BindIndexBuffer(nullptr, 0);
}
void SoftGPU::CopyDisplayToOutput()
{
CopyDisplayToOutputInternal();
}
void SoftGPU::CopyDisplayToOutputInternal()
{
void SoftGPU::CopyDisplayToOutput() {
// The display always shows 480x272.
CopyToCurrentFboFromDisplayRam(FB_WIDTH, FB_HEIGHT);
framebufferDirty_ = false;

View File

@ -97,8 +97,6 @@ protected:
void CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight);
private:
void CopyDisplayToOutputInternal() override;
bool framebufferDirty_;
u32 displayFramebuf_;
u32 displayStride_;

View File

@ -332,21 +332,17 @@ void GPU_Vulkan::BuildReportingInfo() {
Reporting::UpdateConfig();
}
void GPU_Vulkan::ReinitializeInternal() {
void GPU_Vulkan::Reinitialize() {
GPUCommon::Reinitialize();
textureCacheVulkan_->Clear(true);
depalShaderCache_.Clear();
framebufferManagerVulkan_->DestroyAllFBOs();
}
void GPU_Vulkan::InitClearInternal() {
void GPU_Vulkan::InitClear() {
bool useNonBufferedRendering = g_Config.iRenderingMode == FB_NON_BUFFERED_MODE;
if (useNonBufferedRendering) {
/*
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0, 0, 0, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
*/
// TODO?
}
}
@ -389,7 +385,7 @@ bool GPU_Vulkan::FramebufferReallyDirty() {
return true;
}
void GPU_Vulkan::CopyDisplayToOutputInternal() {
void GPU_Vulkan::CopyDisplayToOutput() {
// Flush anything left over.
drawEngine_.Flush();

View File

@ -96,9 +96,9 @@ private:
}
void CheckFlushOp(int cmd, u32 diff);
void BuildReportingInfo();
void InitClearInternal() override;
void CopyDisplayToOutputInternal() override;
void ReinitializeInternal() override;
void InitClear() override;
void CopyDisplayToOutput() override;
void Reinitialize() override;
inline void UpdateVsyncInterval(bool force);
void UpdateCmdInfo();