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/.
|
|
|
|
|
2017-02-24 17:59:41 +00:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
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"
|
2017-02-24 17:59:41 +00:00
|
|
|
|
|
|
|
#if PPSSPP_PLATFORM(UWP)
|
|
|
|
#include "GPU/D3D11/GPU_D3D11.h"
|
|
|
|
#else
|
2017-02-24 23:25:46 +00:00
|
|
|
#include "GPU/GLES/GPU_GLES.h"
|
2017-02-24 17:59:41 +00:00
|
|
|
|
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/GPU_DX9.h"
|
2017-02-08 16:47:07 +00:00
|
|
|
#include "GPU/D3D11/GPU_D3D11.h"
|
2015-07-26 20:38:40 +00:00
|
|
|
#endif
|
|
|
|
|
2017-02-24 17:59:41 +00:00
|
|
|
#endif
|
|
|
|
|
2015-07-26 20:38:40 +00:00
|
|
|
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
|
|
|
|
2017-01-30 15:50:35 +00:00
|
|
|
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
|
2017-02-24 17:59:41 +00:00
|
|
|
#if PPSSPP_PLATFORM(UWP)
|
|
|
|
SetGPU(new GPU_D3D11(ctx, draw));
|
|
|
|
return true;
|
|
|
|
#else
|
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:
|
2017-01-30 15:50:35 +00:00
|
|
|
SetGPU(new GPU_GLES(ctx, draw));
|
2015-07-26 20:38:40 +00:00
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_SOFTWARE:
|
2017-01-30 15:50:35 +00:00
|
|
|
SetGPU(new SoftGPU(ctx, draw));
|
2015-07-26 20:38:40 +00:00
|
|
|
break;
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_DIRECTX9:
|
2017-08-31 20:15:05 +00:00
|
|
|
#if defined(_WIN32) && !defined(__LIBRETRO__)
|
2017-01-30 15:50:35 +00:00
|
|
|
SetGPU(new DIRECTX9_GPU(ctx, draw));
|
2015-07-26 20:38:40 +00:00
|
|
|
break;
|
2017-02-08 16:47:07 +00:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_DIRECTX11:
|
2017-08-31 20:15:05 +00:00
|
|
|
#if defined(_WIN32) && !defined(__LIBRETRO__)
|
2017-02-08 17:07:34 +00:00
|
|
|
SetGPU(new GPU_D3D11(ctx, draw));
|
|
|
|
break;
|
2017-02-08 16:47:07 +00:00
|
|
|
#else
|
2016-03-20 23:25:02 +00:00
|
|
|
return false;
|
2017-02-08 16:47:07 +00:00
|
|
|
#endif
|
2016-04-10 08:21:48 +00:00
|
|
|
case GPUCORE_VULKAN:
|
2016-08-05 17:48:04 +00:00
|
|
|
#ifndef NO_VULKAN
|
2016-10-01 18:22:53 +00:00
|
|
|
if (!ctx) {
|
|
|
|
ERROR_LOG(G3D, "Unable to init Vulkan GPU backend, no context");
|
|
|
|
break;
|
|
|
|
}
|
2017-01-30 15:50:35 +00:00
|
|
|
SetGPU(new GPU_Vulkan(ctx, draw));
|
2016-02-21 21:12:19 +00:00
|
|
|
#endif
|
2016-08-05 17:48:04 +00:00
|
|
|
break;
|
2015-07-26 20:38:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gpu != NULL;
|
2017-02-24 17:59:41 +00:00
|
|
|
#endif
|
2015-07-26 20:38:40 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|