2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- 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
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// 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/.
|
|
|
|
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "GPU/ge_constants.h"
|
|
|
|
#include "GPU/GPUState.h"
|
|
|
|
#include "GPU/GLES/ShaderManager.h"
|
|
|
|
#include "GPU/GLES/GLES_GPU.h"
|
|
|
|
#include "GPU/Null/NullGpu.h"
|
|
|
|
#include "GPU/Software/SoftGpu.h"
|
|
|
|
#include "Core/CoreParameter.h"
|
|
|
|
#include "Core/System.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
GPUgstate gstate;
|
2012-11-18 12:04:49 +00:00
|
|
|
GPUStateCache gstate_c;
|
2012-11-06 16:05:27 +00:00
|
|
|
GPUInterface *gpu;
|
2012-11-18 12:04:49 +00:00
|
|
|
GPUStatistics gpuStats;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-08-07 15:07:13 +00:00
|
|
|
void GPU_Init() {
|
|
|
|
switch (PSP_CoreParameter().gpuCore) {
|
|
|
|
case GPU_NULL:
|
|
|
|
gpu = new NullGPU();
|
|
|
|
break;
|
|
|
|
case GPU_GLES:
|
|
|
|
gpu = new GLES_GPU();
|
|
|
|
break;
|
2013-08-18 08:07:15 +00:00
|
|
|
#ifndef __SYMBIAN32__
|
2013-08-07 15:07:13 +00:00
|
|
|
case GPU_SOFTWARE:
|
2013-06-24 14:03:25 +00:00
|
|
|
gpu = new SoftGPU();
|
2013-08-07 15:07:13 +00:00
|
|
|
break;
|
2013-08-18 08:07:15 +00:00
|
|
|
#endif
|
2013-08-18 08:17:23 +00:00
|
|
|
}
|
2013-08-07 15:07:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_Shutdown() {
|
|
|
|
delete gpu;
|
|
|
|
gpu = 0;
|
|
|
|
}
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
void InitGfxState()
|
|
|
|
{
|
|
|
|
memset(&gstate, 0, sizeof(gstate));
|
2013-02-02 12:38:34 +00:00
|
|
|
memset(&gstate_c, 0, sizeof(gstate_c));
|
2012-11-01 15:19:01 +00:00
|
|
|
for (int i = 0; i < 256; i++) {
|
|
|
|
gstate.cmdmem[i] = i << 24;
|
|
|
|
}
|
2012-11-24 14:19:29 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
gstate.lightingEnable = 0x17000001;
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
static const float identity4x3[12] =
|
2012-11-01 15:19:01 +00:00
|
|
|
{1,0,0,
|
|
|
|
0,1,0,
|
|
|
|
0,0,1,
|
|
|
|
0,0,0,};
|
|
|
|
static const float identity4x4[16] =
|
|
|
|
{1,0,0,0,
|
2012-11-18 12:04:49 +00:00
|
|
|
0,1,0,0,
|
|
|
|
0,0,1,0,
|
|
|
|
0,0,0,1};
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
memcpy(gstate.worldMatrix, identity4x3, 12 * sizeof(float));
|
|
|
|
memcpy(gstate.viewMatrix, identity4x3, 12 * sizeof(float));
|
|
|
|
memcpy(gstate.projMatrix, identity4x4, 16 * sizeof(float));
|
|
|
|
memcpy(gstate.tgenMatrix, identity4x3, 12 * sizeof(float));
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
memcpy(gstate.boneMatrix + i * 12, identity4x3, 12 * sizeof(float));
|
|
|
|
}
|
2012-11-06 16:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ShutdownGfxState()
|
|
|
|
{
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// When you have changed state outside the psp gfx core,
|
|
|
|
// or saved the context and has reloaded it, call this function.
|
|
|
|
void ReapplyGfxState()
|
|
|
|
{
|
2012-11-18 12:04:49 +00:00
|
|
|
if (!gpu)
|
|
|
|
return;
|
2013-08-04 22:15:50 +00:00
|
|
|
gpu->ReapplyGfxState();
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|