2015-07-26 20:38:40 +00:00
|
|
|
// Copyright (c) 2015- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2016-01-05 20:18:43 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2015-07-26 20:38:40 +00:00
|
|
|
#include "Core/Core.h"
|
|
|
|
|
|
|
|
#include "GPU/GPU.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/GPU_GLES.h"
|
2016-02-21 21:12:19 +00:00
|
|
|
#ifndef NO_VULKAN
|
2015-10-10 14:41:19 +00:00
|
|
|
#include "GPU/Vulkan/GPU_Vulkan.h"
|
2016-02-21 21:12:19 +00:00
|
|
|
#endif
|
2015-07-26 20:38:40 +00:00
|
|
|
#include "GPU/Null/NullGpu.h"
|
|
|
|
#include "GPU/Software/SoftGpu.h"
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#include "GPU/Directx9/helper/global.h"
|
|
|
|
#include "GPU/Directx9/GPU_DX9.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GPUStatistics gpuStats;
|
|
|
|
GPUInterface *gpu;
|
|
|
|
GPUDebugInterface *gpuDebug;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static void SetGPU(T *obj) {
|
|
|
|
gpu = obj;
|
|
|
|
gpuDebug = obj;
|
|
|
|
}
|
|
|
|
|
2016-02-10 14:22:28 +00:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#undef new
|
|
|
|
#endif
|
2016-03-20 19:04:49 +00:00
|
|
|
|
|
|
|
bool GPU_Init(GraphicsContext *ctx, Thin3DContext *thin3d) {
|
2015-07-26 20:38:40 +00:00
|
|
|
switch (PSP_CoreParameter().gpuCore) {
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_NULL:
|
2015-07-26 20:38:40 +00:00
|
|
|
SetGPU(new NullGPU());
|
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_GLES:
|
|
|
|
SetGPU(new GPU_GLES(ctx));
|
2015-07-26 20:38:40 +00:00
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_SOFTWARE:
|
2016-03-20 19:04:49 +00:00
|
|
|
SetGPU(new SoftGPU(ctx, thin3d));
|
2015-07-26 20:38:40 +00:00
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_DIRECTX9:
|
2015-07-26 20:38:40 +00:00
|
|
|
#if defined(_WIN32)
|
2016-02-13 18:53:28 +00:00
|
|
|
SetGPU(new DIRECTX9_GPU(ctx));
|
2015-07-26 20:38:40 +00:00
|
|
|
#endif
|
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_DIRECTX11:
|
2016-03-20 23:25:02 +00:00
|
|
|
return false;
|
2016-02-21 21:12:19 +00:00
|
|
|
#ifndef NO_VULKAN
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_VULKAN:
|
2016-01-05 20:18:43 +00:00
|
|
|
SetGPU(new GPU_Vulkan(ctx));
|
2015-10-10 14:41:19 +00:00
|
|
|
break;
|
2016-02-21 21:12:19 +00:00
|
|
|
#endif
|
2015-07-26 20:38:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gpu != NULL;
|
|
|
|
}
|
2016-02-10 14:22:28 +00:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#define new DBG_NEW
|
|
|
|
#endif
|
2015-07-26 20:38:40 +00:00
|
|
|
|
|
|
|
void GPU_Shutdown() {
|
|
|
|
delete gpu;
|
|
|
|
gpu = 0;
|
|
|
|
gpuDebug = 0;
|
|
|
|
}
|