2015-07-26 22:38:40 +02: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 18:59:41 +01:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
2016-01-05 21:18:43 +01:00
|
|
|
#include "Common/GraphicsContext.h"
|
2015-07-26 22:38:40 +02:00
|
|
|
#include "Core/Core.h"
|
|
|
|
|
|
|
|
#include "GPU/GPU.h"
|
|
|
|
#include "GPU/GPUInterface.h"
|
2017-02-24 18:59:41 +01:00
|
|
|
|
|
|
|
#if PPSSPP_PLATFORM(UWP)
|
|
|
|
#include "GPU/D3D11/GPU_D3D11.h"
|
|
|
|
#else
|
2017-02-25 00:25:46 +01:00
|
|
|
#include "GPU/GLES/GPU_GLES.h"
|
2017-02-24 18:59:41 +01:00
|
|
|
|
2016-02-21 22:12:19 +01:00
|
|
|
#ifndef NO_VULKAN
|
2015-10-10 16:41:19 +02:00
|
|
|
#include "GPU/Vulkan/GPU_Vulkan.h"
|
2016-02-21 22:12:19 +01:00
|
|
|
#endif
|
2015-07-26 22:38:40 +02:00
|
|
|
#include "GPU/Null/NullGpu.h"
|
|
|
|
#include "GPU/Software/SoftGpu.h"
|
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
#include "GPU/Directx9/GPU_DX9.h"
|
2017-02-08 17:47:07 +01:00
|
|
|
#include "GPU/D3D11/GPU_D3D11.h"
|
2015-07-26 22:38:40 +02:00
|
|
|
#endif
|
|
|
|
|
2017-02-24 18:59:41 +01:00
|
|
|
#endif
|
|
|
|
|
2015-07-26 22:38:40 +02:00
|
|
|
GPUStatistics gpuStats;
|
|
|
|
GPUInterface *gpu;
|
|
|
|
GPUDebugInterface *gpuDebug;
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
static void SetGPU(T *obj) {
|
|
|
|
gpu = obj;
|
|
|
|
gpuDebug = obj;
|
|
|
|
}
|
|
|
|
|
2016-02-10 15:22:28 +01:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#undef new
|
|
|
|
#endif
|
2016-03-20 20:04:49 +01:00
|
|
|
|
2017-01-30 16:50:35 +01:00
|
|
|
bool GPU_Init(GraphicsContext *ctx, Draw::DrawContext *draw) {
|
2017-02-24 18:59:41 +01:00
|
|
|
#if PPSSPP_PLATFORM(UWP)
|
|
|
|
SetGPU(new GPU_D3D11(ctx, draw));
|
|
|
|
return true;
|
|
|
|
#else
|
2015-07-26 22:38:40 +02:00
|
|
|
switch (PSP_CoreParameter().gpuCore) {
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_NULL:
|
2015-07-26 22:38:40 +02:00
|
|
|
SetGPU(new NullGPU());
|
|
|
|
break;
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_GLES:
|
2017-01-30 16:50:35 +01:00
|
|
|
SetGPU(new GPU_GLES(ctx, draw));
|
2015-07-26 22:38:40 +02:00
|
|
|
break;
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_SOFTWARE:
|
2017-01-30 16:50:35 +01:00
|
|
|
SetGPU(new SoftGPU(ctx, draw));
|
2015-07-26 22:38:40 +02:00
|
|
|
break;
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_DIRECTX9:
|
2015-07-26 22:38:40 +02:00
|
|
|
#if defined(_WIN32)
|
2017-01-30 16:50:35 +01:00
|
|
|
SetGPU(new DIRECTX9_GPU(ctx, draw));
|
2015-07-26 22:38:40 +02:00
|
|
|
break;
|
2017-02-08 17:47:07 +01:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_DIRECTX11:
|
2017-02-08 17:47:07 +01:00
|
|
|
#if defined(_WIN32)
|
2017-02-08 18:07:34 +01:00
|
|
|
SetGPU(new GPU_D3D11(ctx, draw));
|
|
|
|
break;
|
2017-02-08 17:47:07 +01:00
|
|
|
#else
|
2016-03-20 16:25:02 -07:00
|
|
|
return false;
|
2017-02-08 17:47:07 +01:00
|
|
|
#endif
|
2016-04-10 10:21:48 +02:00
|
|
|
case GPUCORE_VULKAN:
|
2016-08-05 10:48:04 -07:00
|
|
|
#ifndef NO_VULKAN
|
2016-10-01 11:22:53 -07:00
|
|
|
if (!ctx) {
|
|
|
|
ERROR_LOG(G3D, "Unable to init Vulkan GPU backend, no context");
|
|
|
|
break;
|
|
|
|
}
|
2017-01-30 16:50:35 +01:00
|
|
|
SetGPU(new GPU_Vulkan(ctx, draw));
|
2016-02-21 22:12:19 +01:00
|
|
|
#endif
|
2016-08-05 10:48:04 -07:00
|
|
|
break;
|
2015-07-26 22:38:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return gpu != NULL;
|
2017-02-24 18:59:41 +01:00
|
|
|
#endif
|
2015-07-26 22:38:40 +02:00
|
|
|
}
|
2016-02-10 15:22:28 +01:00
|
|
|
#ifdef USE_CRT_DBG
|
|
|
|
#define new DBG_NEW
|
|
|
|
#endif
|
2015-07-26 22:38:40 +02:00
|
|
|
|
|
|
|
void GPU_Shutdown() {
|
|
|
|
delete gpu;
|
|
|
|
gpu = 0;
|
|
|
|
gpuDebug = 0;
|
|
|
|
}
|