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:58:25 +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-15 23:00:26 +00:00
|
|
|
#include "base/logging.h"
|
2015-05-13 20:28:02 +00:00
|
|
|
#include "profiler/profiler.h"
|
2013-07-26 22:44:16 +00:00
|
|
|
|
2013-12-29 22:28:31 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
2015-12-31 15:59:40 +00:00
|
|
|
#include "Common/GraphicsContext.h"
|
2013-12-29 22:28:31 +00:00
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
#include "Core/Config.h"
|
2013-12-14 22:54:05 +00:00
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
2015-04-06 01:03:50 +00:00
|
|
|
#include "Core/MemMapHelpers.h"
|
2013-01-30 20:09:53 +00:00
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/Config.h"
|
2013-05-11 05:51:23 +00:00
|
|
|
#include "Core/Reporting.h"
|
2013-01-30 20:09:53 +00:00
|
|
|
#include "Core/System.h"
|
2016-01-17 19:29:34 +00:00
|
|
|
#include "Core/ELF/ParamSFO.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "GPU/GPUState.h"
|
|
|
|
#include "GPU/ge_constants.h"
|
|
|
|
#include "GPU/GeDisasm.h"
|
2015-09-05 19:23:58 +00:00
|
|
|
#include "GPU/Common/FramebufferCommon.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2015-09-06 11:45:17 +00:00
|
|
|
#include "GPU/GLES/GLStateCache.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/ShaderManagerGLES.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/GPU_GLES.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/FramebufferManagerGLES.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/DrawEngineGLES.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/TextureCacheGLES.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2014-03-15 18:44:02 +00:00
|
|
|
#include "Core/MIPS/MIPS.h"
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "Core/HLE/sceKernelThread.h"
|
|
|
|
#include "Core/HLE/sceKernelInterrupt.h"
|
|
|
|
#include "Core/HLE/sceGe.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2015-09-06 11:36:33 +00:00
|
|
|
#ifdef _WIN32
|
2015-11-03 22:22:09 +00:00
|
|
|
#include "Windows/GPU/WindowsGLContext.h"
|
2015-09-06 11:36:33 +00:00
|
|
|
#endif
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
enum {
|
|
|
|
FLAG_FLUSHBEFORE = 1,
|
|
|
|
FLAG_FLUSHBEFOREONCHANGE = 2,
|
|
|
|
FLAG_EXECUTE = 4, // needs to actually be executed. unused for now.
|
2014-04-13 17:23:21 +00:00
|
|
|
FLAG_EXECUTEONCHANGE = 8,
|
2014-03-29 21:10:35 +00:00
|
|
|
FLAG_READS_PC = 16,
|
|
|
|
FLAG_WRITES_PC = 32,
|
2017-01-23 22:15:54 +00:00
|
|
|
FLAG_DIRTYONCHANGE = 64, // NOTE: Either this or FLAG_EXECUTE*, not both!
|
2013-02-11 18:03:11 +00:00
|
|
|
};
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
struct CommandTableEntry {
|
2017-01-23 22:15:54 +00:00
|
|
|
uint8_t cmd;
|
|
|
|
uint8_t flags;
|
|
|
|
uint64_t dirtyUniform;
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::CmdFunc func;
|
2013-08-23 11:35:23 +00:00
|
|
|
};
|
|
|
|
|
2014-12-06 10:21:07 +00:00
|
|
|
// This table gets crunched into a faster form by init.
|
|
|
|
// TODO: Share this table between the backends. Will have to make another indirection for the function pointers though..
|
2013-08-23 11:35:23 +00:00
|
|
|
static const CommandTableEntry commandTable[] = {
|
|
|
|
// Changes that dirty the framebuffer
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_FRAMEBUFPTR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_FramebufType},
|
|
|
|
{GE_CMD_FRAMEBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_FramebufType},
|
|
|
|
{GE_CMD_FRAMEBUFPIXFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_FramebufType},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_ZBUFPTR, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ZBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// Changes that dirty uniforms
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_FOGCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_FOGCOLOR, &GPU_GLES::Execute_FogColor},
|
|
|
|
{GE_CMD_FOG1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_FOGCOEF, &GPU_GLES::Execute_FogCoef},
|
|
|
|
{GE_CMD_FOG2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_FOGCOEF, &GPU_GLES::Execute_FogCoef},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-09-14 21:33:55 +00:00
|
|
|
// Should these maybe flush?
|
2015-08-26 11:26:08 +00:00
|
|
|
{GE_CMD_MINZ, FLAG_FLUSHBEFOREONCHANGE, DIRTY_DEPTHRANGE},
|
|
|
|
{GE_CMD_MAXZ, FLAG_FLUSHBEFOREONCHANGE, DIRTY_DEPTHRANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changes that dirty texture scaling.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_TEXMAPMODE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_UVSCALEOFFSET, &GPU_GLES::Execute_TexMapMode},
|
|
|
|
{GE_CMD_TEXSCALEU, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_UVSCALEOFFSET, &GPU_GLES::Execute_TexScaleU},
|
|
|
|
{GE_CMD_TEXSCALEV, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_UVSCALEOFFSET, &GPU_GLES::Execute_TexScaleV},
|
|
|
|
{GE_CMD_TEXOFFSETU, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_UVSCALEOFFSET, &GPU_GLES::Execute_TexOffsetU},
|
|
|
|
{GE_CMD_TEXOFFSETV, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_UVSCALEOFFSET, &GPU_GLES::Execute_TexOffsetV},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changes that dirty the current texture. Really should be possible to avoid executing these if we compile
|
|
|
|
// by adding some more flags.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPU_GLES::Execute_TexSize0},
|
|
|
|
{GE_CMD_TEXSIZE1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXSIZE7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexSizeN},
|
|
|
|
{GE_CMD_TEXFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexFormat},
|
|
|
|
{GE_CMD_TEXLEVEL, FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexLevel},
|
|
|
|
{GE_CMD_TEXADDR0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddr0},
|
|
|
|
{GE_CMD_TEXADDR1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXADDR7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexAddrN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufw0},
|
|
|
|
{GE_CMD_TEXBUFWIDTH1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
|
|
|
{GE_CMD_TEXBUFWIDTH7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexBufwN},
|
2014-03-29 21:10:35 +00:00
|
|
|
// These must flush on change, so that LoadClut doesn't have to always flush.
|
|
|
|
{GE_CMD_CLUTADDR, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_CLUTADDRUPPER, FLAG_FLUSHBEFOREONCHANGE},
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_CLUTFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ClutFormat},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// These affect the fragment shader so need flushing.
|
|
|
|
{GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE},
|
2014-04-13 20:01:18 +00:00
|
|
|
{GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexParamType},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_SHADEMODE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_TEXFUNC, FLAG_FLUSHBEFOREONCHANGE},
|
2014-04-22 05:53:19 +00:00
|
|
|
{GE_CMD_COLORTEST, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_ALPHATESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_COLORTESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_COLORTESTMASK, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_ALPHACOLORMASK, &GPU_GLES::Execute_ColorTestMask},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// These change the vertex shader so need flushing.
|
2014-09-15 14:08:55 +00:00
|
|
|
{GE_CMD_REVERSENORMAL, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_LIGHTINGENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTENABLE0, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTENABLE1, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTENABLE2, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTENABLE3, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTTYPE0, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTTYPE1, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTTYPE2, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LIGHTTYPE3, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_MATERIALUPDATE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// This changes both shaders so need flushing.
|
|
|
|
{GE_CMD_LIGHTMODE, FLAG_FLUSHBEFOREONCHANGE},
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_TEXFILTER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexParamType},
|
|
|
|
{GE_CMD_TEXWRAP, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_TexParamType},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Uniform changes
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_ALPHATEST, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_ALPHACOLORREF | DIRTY_ALPHACOLORMASK, &GPU_GLES::Execute_AlphaTest},
|
|
|
|
{GE_CMD_COLORREF, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ColorRef},
|
|
|
|
{GE_CMD_TEXENVCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_TEXENV, &GPU_GLES::Execute_TexEnvColor},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Simple render state changes. Handled in StateMapping.cpp.
|
2013-09-20 06:16:17 +00:00
|
|
|
{GE_CMD_OFFSETX, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_OFFSETY, FLAG_FLUSHBEFOREONCHANGE},
|
2013-09-14 21:33:55 +00:00
|
|
|
{GE_CMD_CULL, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_CULLFACEENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_DITHERENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_STENCILOP, FLAG_FLUSHBEFOREONCHANGE},
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_STENCILREPLACEVALUE, &GPU_GLES::Execute_StencilTest},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_STENCILTESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ALPHABLENDENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_BLENDMODE, FLAG_FLUSHBEFOREONCHANGE},
|
2014-06-14 05:49:28 +00:00
|
|
|
{GE_CMD_BLENDFIXEDA, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_BLENDFIXEDB, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_MASKRGB, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_MASKALPHA, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ZTEST, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ZTESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ZWRITEDISABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LOGICOP, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LOGICOPENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// Can probably ignore this one as we don't support AA lines.
|
|
|
|
{GE_CMD_ANTIALIASENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// Morph weights. TODO: Remove precomputation?
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_MORPHWEIGHT0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MORPHWEIGHT7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Control spline/bezier patches. Don't really require flushing as such, but meh.
|
|
|
|
{GE_CMD_PATCHDIVISION, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_PATCHPRIMITIVE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_PATCHFACING, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_PATCHCULLENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// Viewport.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_VIEWPORTXSCALE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ViewportType},
|
|
|
|
{GE_CMD_VIEWPORTYSCALE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ViewportType},
|
|
|
|
{GE_CMD_VIEWPORTXCENTER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ViewportType},
|
|
|
|
{GE_CMD_VIEWPORTYCENTER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_ViewportType},
|
|
|
|
{GE_CMD_VIEWPORTZSCALE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_DEPTHRANGE, &GPU_GLES::Execute_ViewportZType},
|
|
|
|
{GE_CMD_VIEWPORTZCENTER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_DEPTHRANGE, &GPU_GLES::Execute_ViewportZType},
|
2016-01-19 04:53:38 +00:00
|
|
|
{GE_CMD_CLIPENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-10-08 01:29:51 +00:00
|
|
|
// Region
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_REGION1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_Region},
|
|
|
|
{GE_CMD_REGION2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_Region},
|
2013-10-08 01:29:51 +00:00
|
|
|
|
|
|
|
// Scissor
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_SCISSOR1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_Scissor},
|
|
|
|
{GE_CMD_SCISSOR2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_Scissor},
|
2013-10-08 01:29:51 +00:00
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
// These dirty various vertex shader uniforms. Could embed information about that in this table and call dirtyuniform directly, hm...
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_AMBIENTCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_AMBIENT, &GPU_GLES::Execute_Ambient},
|
|
|
|
{GE_CMD_AMBIENTALPHA, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_AMBIENT, &GPU_GLES::Execute_Ambient},
|
|
|
|
{GE_CMD_MATERIALDIFFUSE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATDIFFUSE, &GPU_GLES::Execute_MaterialDiffuse},
|
|
|
|
{GE_CMD_MATERIALEMISSIVE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATEMISSIVE, &GPU_GLES::Execute_MaterialEmissive},
|
|
|
|
{GE_CMD_MATERIALAMBIENT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATAMBIENTALPHA, &GPU_GLES::Execute_MaterialAmbient},
|
|
|
|
{GE_CMD_MATERIALALPHA, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATAMBIENTALPHA, &GPU_GLES::Execute_MaterialAmbient},
|
|
|
|
{GE_CMD_MATERIALSPECULAR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATSPECULAR, &GPU_GLES::Execute_MaterialSpecular},
|
|
|
|
{GE_CMD_MATERIALSPECULARCOEF, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_MATSPECULAR, &GPU_GLES::Execute_MaterialSpecular},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2014-04-22 05:47:44 +00:00
|
|
|
// These dirty uniforms, which could be table-ized to avoid execute.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_LX0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LY0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LZ0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LX3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LY3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LZ3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
|
|
|
|
{GE_CMD_LDX0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LDY0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LDZ0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LDX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LDY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LDZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LDX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LDY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LDZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LDX3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LDY3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LDZ3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
|
|
|
|
{GE_CMD_LKA0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LKB0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LKC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LKA1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LKB1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LKC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LKA2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LKB2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LKC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LKA3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LKB3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LKC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
|
|
|
|
{GE_CMD_LKS0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LKS1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LKS2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LKS3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
|
|
|
|
{GE_CMD_LKO0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LKO1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LKO2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LKO3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
|
|
|
|
{GE_CMD_LAC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LDC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LSC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT0, &GPU_GLES::Execute_Light0Param},
|
|
|
|
{GE_CMD_LAC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LDC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LSC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT1, &GPU_GLES::Execute_Light1Param},
|
|
|
|
{GE_CMD_LAC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LDC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LSC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT2, &GPU_GLES::Execute_Light2Param},
|
|
|
|
{GE_CMD_LAC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LDC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
|
|
|
{GE_CMD_LSC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, DIRTY_LIGHT3, &GPU_GLES::Execute_Light3Param},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Ignored commands
|
|
|
|
{GE_CMD_TEXFLUSH, 0},
|
|
|
|
{GE_CMD_TEXLODSLOPE, 0},
|
|
|
|
{GE_CMD_TEXSYNC, 0},
|
|
|
|
|
|
|
|
// These are just nop or part of other later commands.
|
|
|
|
{GE_CMD_NOP, 0},
|
|
|
|
{GE_CMD_BASE, 0},
|
|
|
|
{GE_CMD_TRANSFERSRC, 0},
|
|
|
|
{GE_CMD_TRANSFERSRCW, 0},
|
|
|
|
{GE_CMD_TRANSFERDST, 0},
|
|
|
|
{GE_CMD_TRANSFERDSTW, 0},
|
|
|
|
{GE_CMD_TRANSFERSRCPOS, 0},
|
|
|
|
{GE_CMD_TRANSFERDSTPOS, 0},
|
|
|
|
{GE_CMD_TRANSFERSIZE, 0},
|
|
|
|
|
2013-08-23 12:22:26 +00:00
|
|
|
// From Common. No flushing but definitely need execute.
|
2014-12-06 10:21:07 +00:00
|
|
|
{GE_CMD_OFFSETADDR, FLAG_EXECUTE, 0, &GPUCommon::Execute_OffsetAddr},
|
|
|
|
{GE_CMD_ORIGIN, FLAG_EXECUTE | FLAG_READS_PC, 0, &GPUCommon::Execute_Origin}, // Really?
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_PRIM, FLAG_EXECUTE, 0, &GPU_GLES::Execute_Prim},
|
2014-12-06 10:21:07 +00:00
|
|
|
{GE_CMD_JUMP, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPUCommon::Execute_Jump},
|
|
|
|
{GE_CMD_CALL, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPUCommon::Execute_Call},
|
|
|
|
{GE_CMD_RET, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPUCommon::Execute_Ret},
|
|
|
|
{GE_CMD_END, FLAG_FLUSHBEFORE | FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPUCommon::Execute_End}, // Flush?
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_VADDR, FLAG_EXECUTE, 0, &GPU_GLES::Execute_Vaddr},
|
|
|
|
{GE_CMD_IADDR, FLAG_EXECUTE, 0, &GPU_GLES::Execute_Iaddr},
|
2014-12-06 10:21:07 +00:00
|
|
|
{GE_CMD_BJUMP, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPUCommon::Execute_BJump}, // EXECUTE
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_BOUNDINGBOX, FLAG_EXECUTE, 0, &GPU_GLES::Execute_BoundingBox}, // + FLUSHBEFORE when we implement... or not, do we need to?
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changing the vertex type requires us to flush.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE, 0, &GPU_GLES::Execute_VertexType},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_BEZIER, FLAG_FLUSHBEFORE | FLAG_EXECUTE, 0, &GPU_GLES::Execute_Bezier},
|
|
|
|
{GE_CMD_SPLINE, FLAG_FLUSHBEFORE | FLAG_EXECUTE, 0, &GPU_GLES::Execute_Spline},
|
2013-08-23 12:22:26 +00:00
|
|
|
|
|
|
|
// These two are actually processed in CMD_END.
|
2013-08-23 14:31:03 +00:00
|
|
|
{GE_CMD_SIGNAL, FLAG_FLUSHBEFORE},
|
|
|
|
{GE_CMD_FINISH, FLAG_FLUSHBEFORE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changes that trigger data copies. Only flushing on change for LOADCLUT must be a bit of a hack...
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_LOADCLUT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE, 0, &GPU_GLES::Execute_LoadClut},
|
2017-01-23 15:57:16 +00:00
|
|
|
{GE_CMD_TRANSFERSTART, FLAG_FLUSHBEFORE | FLAG_EXECUTE | FLAG_READS_PC, 0, &GPUCommon::Execute_BlockTransferStart},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// We don't use the dither table.
|
|
|
|
{GE_CMD_DITH0},
|
|
|
|
{GE_CMD_DITH1},
|
|
|
|
{GE_CMD_DITH2},
|
|
|
|
{GE_CMD_DITH3},
|
|
|
|
|
2013-01-20 12:15:46 +00:00
|
|
|
// These handle their own flushing.
|
2016-04-10 08:21:48 +00:00
|
|
|
{GE_CMD_WORLDMATRIXNUMBER, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPU_GLES::Execute_WorldMtxNum},
|
|
|
|
{GE_CMD_WORLDMATRIXDATA, FLAG_EXECUTE, 0, &GPU_GLES::Execute_WorldMtxData},
|
|
|
|
{GE_CMD_VIEWMATRIXNUMBER, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPU_GLES::Execute_ViewMtxNum},
|
|
|
|
{GE_CMD_VIEWMATRIXDATA, FLAG_EXECUTE, 0, &GPU_GLES::Execute_ViewMtxData},
|
|
|
|
{GE_CMD_PROJMATRIXNUMBER, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPU_GLES::Execute_ProjMtxNum},
|
|
|
|
{GE_CMD_PROJMATRIXDATA, FLAG_EXECUTE, 0, &GPU_GLES::Execute_ProjMtxData},
|
|
|
|
{GE_CMD_TGENMATRIXNUMBER, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPU_GLES::Execute_TgenMtxNum},
|
|
|
|
{GE_CMD_TGENMATRIXDATA, FLAG_EXECUTE, 0, &GPU_GLES::Execute_TgenMtxData},
|
|
|
|
{GE_CMD_BONEMATRIXNUMBER, FLAG_EXECUTE | FLAG_READS_PC | FLAG_WRITES_PC, 0, &GPU_GLES::Execute_BoneMtxNum},
|
|
|
|
{GE_CMD_BONEMATRIXDATA, FLAG_EXECUTE, 0, &GPU_GLES::Execute_BoneMtxData},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2014-04-26 14:58:51 +00:00
|
|
|
// Vertex Screen/Texture/Color
|
|
|
|
{GE_CMD_VSCX, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VSCY, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VSCZ, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VTCS, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VTCT, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VTCQ, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VCV, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VAP, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VFC, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VSCV, FLAG_EXECUTE},
|
|
|
|
|
2013-09-20 13:10:32 +00:00
|
|
|
// "Missing" commands (gaps in the sequence)
|
2013-09-23 04:00:56 +00:00
|
|
|
{GE_CMD_UNKNOWN_03, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_0D, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_11, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_29, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_34, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_35, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_39, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_4E, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_4F, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_52, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_59, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_5A, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_B6, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_B7, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_D1, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_ED, FLAG_EXECUTE},
|
2013-10-08 07:34:17 +00:00
|
|
|
{GE_CMD_UNKNOWN_EF, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_FA, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_FB, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_FC, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_FD, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_FE, FLAG_EXECUTE},
|
2014-04-17 15:05:32 +00:00
|
|
|
// Appears to be debugging related or something? Hit a lot in GoW.
|
|
|
|
{GE_CMD_UNKNOWN_FF, 0},
|
2012-12-21 20:49:09 +00:00
|
|
|
};
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::CommandInfo GPU_GLES::cmdInfo_[256];
|
2014-04-16 14:54:19 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::GPU_GLES(GraphicsContext *ctx)
|
2016-12-21 17:13:58 +00:00
|
|
|
: gfxCtx_(ctx) {
|
2014-06-15 22:19:49 +00:00
|
|
|
UpdateVsyncInterval(true);
|
2015-09-05 17:58:47 +00:00
|
|
|
CheckGPUFeatures();
|
2013-10-09 08:44:12 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_ = new ShaderManagerGLES();
|
2017-01-21 21:16:30 +00:00
|
|
|
framebufferManagerGL_ = new FramebufferManagerGLES();
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManager_ = framebufferManagerGL_;
|
2017-01-21 21:16:30 +00:00
|
|
|
textureCacheGL_ = new TextureCacheGLES();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCache_ = textureCacheGL_;
|
2017-01-23 20:08:16 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManager_ = shaderManagerGL_;
|
2017-01-23 20:08:16 +00:00
|
|
|
drawEngineCommon_ = &drawEngine_;
|
2016-12-21 17:07:17 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
drawEngine_.SetShaderManager(shaderManagerGL_);
|
2016-12-21 17:07:17 +00:00
|
|
|
drawEngine_.SetTextureCache(textureCacheGL_);
|
|
|
|
drawEngine_.SetFramebufferManager(framebufferManagerGL_);
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.SetFragmentTestCache(&fragmentTestCache_);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->Init();
|
|
|
|
framebufferManagerGL_->SetTextureCache(textureCacheGL_);
|
2017-01-23 19:48:23 +00:00
|
|
|
framebufferManagerGL_->SetShaderManager(shaderManagerGL_);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->SetTransformDrawEngine(&drawEngine_);
|
|
|
|
textureCacheGL_->SetFramebufferManager(framebufferManagerGL_);
|
|
|
|
textureCacheGL_->SetDepalShaderCache(&depalShaderCache_);
|
2017-01-23 19:48:23 +00:00
|
|
|
textureCacheGL_->SetShaderManager(shaderManagerGL_);
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->SetTransformDrawEngine(&drawEngine_);
|
|
|
|
fragmentTestCache_.SetTextureCache(textureCacheGL_);
|
2013-01-30 19:40:26 +00:00
|
|
|
|
2012-11-22 19:57:41 +00:00
|
|
|
// Sanity check gstate
|
|
|
|
if ((int *)&gstate.transferstart - (int *)&gstate != 0xEA) {
|
|
|
|
ERROR_LOG(G3D, "gstate has drifted out of sync!");
|
|
|
|
}
|
2012-12-21 20:49:09 +00:00
|
|
|
|
2014-04-17 08:36:24 +00:00
|
|
|
// Sanity check cmdInfo_ table - no dupes please
|
2013-08-23 11:35:23 +00:00
|
|
|
std::set<u8> dupeCheck;
|
2014-04-17 08:36:24 +00:00
|
|
|
memset(cmdInfo_, 0, sizeof(cmdInfo_));
|
2013-08-23 11:35:23 +00:00
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(commandTable); i++) {
|
2014-04-17 08:36:24 +00:00
|
|
|
const u8 cmd = commandTable[i].cmd;
|
2013-08-23 11:35:23 +00:00
|
|
|
if (dupeCheck.find(cmd) != dupeCheck.end()) {
|
|
|
|
ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd);
|
|
|
|
} else {
|
|
|
|
dupeCheck.insert(cmd);
|
|
|
|
}
|
2014-04-17 08:36:24 +00:00
|
|
|
cmdInfo_[cmd].flags |= commandTable[i].flags;
|
|
|
|
cmdInfo_[cmd].func = commandTable[i].func;
|
|
|
|
if (!cmdInfo_[cmd].func) {
|
2016-04-10 08:21:48 +00:00
|
|
|
cmdInfo_[cmd].func = &GPU_GLES::Execute_Generic;
|
2014-04-16 14:54:19 +00:00
|
|
|
}
|
2012-12-26 23:18:45 +00:00
|
|
|
}
|
2013-08-23 11:35:23 +00:00
|
|
|
// Find commands missing from the table.
|
|
|
|
for (int i = 0; i < 0xEF; i++) {
|
|
|
|
if (dupeCheck.find((u8)i) == dupeCheck.end()) {
|
|
|
|
ERROR_LOG(G3D, "Command missing from table: %02x (%i)", i, i);
|
|
|
|
}
|
2012-12-21 20:49:09 +00:00
|
|
|
}
|
2013-04-29 00:49:17 +00:00
|
|
|
|
2013-10-09 08:44:12 +00:00
|
|
|
// No need to flush before the tex scale/offset commands if we are baking
|
|
|
|
// the tex scale/offset into the vertices anyway.
|
2013-10-09 21:09:16 +00:00
|
|
|
|
2014-06-29 04:51:25 +00:00
|
|
|
UpdateCmdInfo();
|
2013-11-10 12:18:52 +00:00
|
|
|
|
2013-04-29 00:49:17 +00:00
|
|
|
BuildReportingInfo();
|
2014-06-15 22:19:49 +00:00
|
|
|
// Update again after init to be sure of any silly driver problems.
|
|
|
|
UpdateVsyncInterval(true);
|
2014-12-30 23:26:16 +00:00
|
|
|
|
|
|
|
// Some of our defaults are different from hw defaults, let's assert them.
|
|
|
|
// We restore each frame anyway, but here is convenient for tests.
|
|
|
|
glstate.Restore();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.RestoreVAO();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->NotifyConfigChanged();
|
2016-01-17 16:11:51 +00:00
|
|
|
|
|
|
|
// Load shader cache.
|
2016-01-17 20:35:24 +00:00
|
|
|
std::string discID = g_paramSFO.GetValueString("DISC_ID");
|
|
|
|
if (discID.size()) {
|
2016-01-17 21:11:28 +00:00
|
|
|
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
|
|
|
|
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + g_paramSFO.GetValueString("DISC_ID") + ".glshadercache";
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->LoadAndPrecompile(shaderCachePath_);
|
2016-01-17 20:35:24 +00:00
|
|
|
}
|
2012-11-20 09:59:23 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::~GPU_GLES() {
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->DestroyAllFBOs(true);
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->ClearCache(true);
|
2014-03-30 13:37:51 +00:00
|
|
|
depalShaderCache_.Clear();
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_.Clear();
|
2016-01-17 21:11:28 +00:00
|
|
|
if (!shaderCachePath_.empty()) {
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->Save(shaderCachePath_);
|
2016-01-17 21:11:28 +00:00
|
|
|
}
|
2017-01-23 19:48:23 +00:00
|
|
|
delete shaderManagerGL_;
|
|
|
|
shaderManagerGL_ = nullptr;
|
2015-09-06 11:36:33 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2015-12-31 15:59:40 +00:00
|
|
|
gfxCtx_->SwapInterval(0);
|
2015-09-06 11:36:33 +00:00
|
|
|
#endif
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
2015-09-05 17:58:47 +00:00
|
|
|
// Take the raw GL extension and versioning data and turn into feature flags.
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::CheckGPUFeatures() {
|
2015-09-05 17:58:47 +00:00
|
|
|
u32 features = 0;
|
2015-11-28 00:01:25 +00:00
|
|
|
if (gl_extensions.ARB_blend_func_extended || gl_extensions.EXT_blend_func_extended) {
|
2015-09-05 20:11:28 +00:00
|
|
|
if (gl_extensions.gpuVendor == GPU_VENDOR_INTEL || !gl_extensions.VersionGEThan(3, 0, 0)) {
|
|
|
|
// Don't use this extension to off on sub 3.0 OpenGL versions as it does not seem reliable
|
|
|
|
// Also on Intel, see https://github.com/hrydgard/ppsspp/issues/4867
|
|
|
|
} else {
|
2016-10-12 09:13:16 +00:00
|
|
|
#ifdef __ANDROID__
|
2016-06-05 07:14:33 +00:00
|
|
|
// This appears to be broken on nVidia Shield TV.
|
|
|
|
if (gl_extensions.gpuVendor != GPU_VENDOR_NVIDIA) {
|
|
|
|
features |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
|
|
|
}
|
|
|
|
#else
|
2015-09-05 20:11:28 +00:00
|
|
|
features |= GPU_SUPPORTS_DUALSOURCE_BLEND;
|
2016-06-05 07:14:33 +00:00
|
|
|
#endif
|
2015-09-05 20:11:28 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-05 17:58:47 +00:00
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
if (gl_extensions.IsGLES) {
|
|
|
|
if (gl_extensions.GLES3)
|
|
|
|
features |= GPU_SUPPORTS_GLSL_ES_300;
|
|
|
|
} else {
|
|
|
|
if (gl_extensions.VersionGEThan(3, 3, 0))
|
|
|
|
features |= GPU_SUPPORTS_GLSL_330;
|
|
|
|
}
|
|
|
|
|
2015-09-05 17:58:47 +00:00
|
|
|
if (gl_extensions.EXT_shader_framebuffer_fetch || gl_extensions.NV_shader_framebuffer_fetch || gl_extensions.ARM_shader_framebuffer_fetch) {
|
2016-04-09 19:08:43 +00:00
|
|
|
// This has caused problems in the past. Let's only enable on GLES3.
|
|
|
|
if (features & GPU_SUPPORTS_GLSL_ES_300) {
|
|
|
|
features |= GPU_SUPPORTS_ANY_FRAMEBUFFER_FETCH;
|
|
|
|
}
|
2015-09-05 17:58:47 +00:00
|
|
|
}
|
|
|
|
|
2015-09-05 20:40:45 +00:00
|
|
|
if (gl_extensions.ARB_framebuffer_object || gl_extensions.EXT_framebuffer_object || gl_extensions.IsGLES) {
|
|
|
|
features |= GPU_SUPPORTS_FBO;
|
|
|
|
}
|
|
|
|
if (gl_extensions.ARB_framebuffer_object || gl_extensions.GLES3) {
|
|
|
|
features |= GPU_SUPPORTS_ARB_FRAMEBUFFER_BLIT;
|
|
|
|
}
|
|
|
|
if (gl_extensions.NV_framebuffer_blit) {
|
|
|
|
features |= GPU_SUPPORTS_NV_FRAMEBUFFER_BLIT;
|
2015-09-05 17:58:47 +00:00
|
|
|
}
|
2015-12-15 05:12:50 +00:00
|
|
|
if (gl_extensions.ARB_vertex_array_object && gl_extensions.IsCoreContext) {
|
2015-12-14 06:48:21 +00:00
|
|
|
features |= GPU_SUPPORTS_VAO;
|
|
|
|
}
|
2015-09-05 17:58:47 +00:00
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
bool useCPU = false;
|
|
|
|
if (!gl_extensions.IsGLES) {
|
|
|
|
// Urrgh, we don't even define FB_READFBOMEMORY_CPU on mobile
|
2015-09-05 17:58:47 +00:00
|
|
|
#ifndef USING_GLES2
|
2015-09-05 19:23:58 +00:00
|
|
|
useCPU = g_Config.iRenderingMode == FB_READFBOMEMORY_CPU;
|
|
|
|
#endif
|
|
|
|
// Some cards or drivers seem to always dither when downloading a framebuffer to 16-bit.
|
|
|
|
// This causes glitches in games that expect the exact values.
|
|
|
|
// It has not been experienced on NVIDIA cards, so those are left using the GPU (which is faster.)
|
|
|
|
if (g_Config.iRenderingMode == FB_BUFFERED_MODE) {
|
|
|
|
if (gl_extensions.gpuVendor != GPU_VENDOR_NVIDIA || gl_extensions.ver[0] < 3) {
|
|
|
|
useCPU = true;
|
|
|
|
}
|
2015-09-05 17:58:47 +00:00
|
|
|
}
|
2015-09-05 19:23:58 +00:00
|
|
|
} else {
|
|
|
|
useCPU = true;
|
2015-09-05 17:58:47 +00:00
|
|
|
}
|
2015-09-05 19:23:58 +00:00
|
|
|
|
|
|
|
if (useCPU)
|
2015-09-05 17:58:47 +00:00
|
|
|
features |= GPU_PREFER_CPU_DOWNLOAD;
|
|
|
|
|
|
|
|
if ((gl_extensions.gpuVendor == GPU_VENDOR_NVIDIA) || (gl_extensions.gpuVendor == GPU_VENDOR_AMD))
|
|
|
|
features |= GPU_PREFER_REVERSE_COLOR_ORDER;
|
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
if (gl_extensions.OES_texture_npot)
|
|
|
|
features |= GPU_SUPPORTS_OES_TEXTURE_NPOT;
|
|
|
|
|
|
|
|
if (gl_extensions.EXT_unpack_subimage || !gl_extensions.IsGLES)
|
|
|
|
features |= GPU_SUPPORTS_UNPACK_SUBIMAGE;
|
|
|
|
|
|
|
|
if (gl_extensions.EXT_blend_minmax || gl_extensions.GLES3)
|
|
|
|
features |= GPU_SUPPORTS_BLEND_MINMAX;
|
|
|
|
|
2015-12-06 18:39:21 +00:00
|
|
|
if (gl_extensions.OES_copy_image || gl_extensions.NV_copy_image || gl_extensions.EXT_copy_image || gl_extensions.ARB_copy_image)
|
|
|
|
features |= GPU_SUPPORTS_ANY_COPY_IMAGE;
|
|
|
|
|
2015-09-05 20:11:28 +00:00
|
|
|
if (!gl_extensions.IsGLES)
|
|
|
|
features |= GPU_SUPPORTS_LOGIC_OP;
|
|
|
|
|
2015-09-26 14:01:16 +00:00
|
|
|
if (gl_extensions.GLES3 || !gl_extensions.IsGLES)
|
2015-09-05 21:09:06 +00:00
|
|
|
features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL;
|
2015-09-26 14:01:16 +00:00
|
|
|
|
2016-03-18 04:56:04 +00:00
|
|
|
features |= GPU_SUPPORTS_ANISOTROPY;
|
|
|
|
|
2016-01-21 06:01:18 +00:00
|
|
|
// If we already have a 16-bit depth buffer, we don't need to round.
|
|
|
|
if (fbo_standard_z_depth() > 16) {
|
2016-02-07 04:42:01 +00:00
|
|
|
if (!g_Config.bHighQualityDepth && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) {
|
2016-01-21 06:01:18 +00:00
|
|
|
features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT;
|
|
|
|
} else if (PSP_CoreParameter().compat.flags().PixelDepthRounding) {
|
|
|
|
if (!gl_extensions.IsGLES || gl_extensions.GLES3) {
|
|
|
|
// Use fragment rounding on desktop and GLES3, most accurate.
|
|
|
|
features |= GPU_ROUND_FRAGMENT_DEPTH_TO_16BIT;
|
2016-02-07 04:42:01 +00:00
|
|
|
} else if (fbo_standard_z_depth() == 24 && (features & GPU_SUPPORTS_ACCURATE_DEPTH) != 0) {
|
2016-01-21 06:01:18 +00:00
|
|
|
// Here we can simulate a 16 bit depth buffer by scaling.
|
|
|
|
// Note that the depth buffer is fixed point, not floating, so dividing by 256 is pretty good.
|
|
|
|
features |= GPU_SCALE_DEPTH_FROM_24BIT_TO_16BIT;
|
|
|
|
} else {
|
|
|
|
// At least do vertex rounding if nothing else.
|
|
|
|
features |= GPU_ROUND_DEPTH_TO_16BIT;
|
|
|
|
}
|
|
|
|
} else if (PSP_CoreParameter().compat.flags().VertexDepthRounding) {
|
|
|
|
features |= GPU_ROUND_DEPTH_TO_16BIT;
|
2015-10-11 18:44:58 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-05 21:09:06 +00:00
|
|
|
|
2016-02-07 04:28:45 +00:00
|
|
|
// The Phantasy Star hack :(
|
|
|
|
if (PSP_CoreParameter().compat.flags().DepthRangeHack && (features & GPU_SUPPORTS_ACCURATE_DEPTH) == 0) {
|
|
|
|
features |= GPU_USE_DEPTH_RANGE_HACK;
|
|
|
|
}
|
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
#ifdef MOBILE_DEVICE
|
|
|
|
// Arguably, we should turn off GPU_IS_MOBILE on like modern Tegras, etc.
|
|
|
|
features |= GPU_IS_MOBILE;
|
|
|
|
#endif
|
|
|
|
|
2015-09-05 17:58:47 +00:00
|
|
|
gstate_c.featureFlags = features;
|
|
|
|
}
|
|
|
|
|
2013-04-29 00:49:17 +00:00
|
|
|
// Let's avoid passing nulls into snprintf().
|
|
|
|
static const char *GetGLStringAlways(GLenum name) {
|
|
|
|
const GLubyte *value = glGetString(name);
|
|
|
|
if (!value)
|
|
|
|
return "?";
|
|
|
|
return (const char *)value;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Needs to be called on GPU thread, not reporting thread.
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::BuildReportingInfo() {
|
2013-04-29 00:49:17 +00:00
|
|
|
const char *glVendor = GetGLStringAlways(GL_VENDOR);
|
|
|
|
const char *glRenderer = GetGLStringAlways(GL_RENDERER);
|
|
|
|
const char *glVersion = GetGLStringAlways(GL_VERSION);
|
|
|
|
const char *glSlVersion = GetGLStringAlways(GL_SHADING_LANGUAGE_VERSION);
|
2015-12-23 23:30:08 +00:00
|
|
|
const char *glExtensions = nullptr;
|
|
|
|
|
|
|
|
if (gl_extensions.VersionGEThan(3, 0)) {
|
|
|
|
glExtensions = g_all_gl_extensions.c_str();
|
|
|
|
} else {
|
|
|
|
glExtensions = GetGLStringAlways(GL_EXTENSIONS);
|
|
|
|
}
|
2013-04-29 00:49:17 +00:00
|
|
|
|
2013-05-12 08:38:42 +00:00
|
|
|
char temp[16384];
|
2013-04-29 00:49:17 +00:00
|
|
|
snprintf(temp, sizeof(temp), "%s (%s %s), %s (extensions: %s)", glVersion, glVendor, glRenderer, glSlVersion, glExtensions);
|
2013-04-29 07:30:54 +00:00
|
|
|
reportingPrimaryInfo_ = glVendor;
|
|
|
|
reportingFullInfo_ = temp;
|
2014-02-15 23:18:01 +00:00
|
|
|
|
|
|
|
Reporting::UpdateConfig();
|
2013-04-29 00:49:17 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::DeviceLost() {
|
2016-04-10 08:27:28 +00:00
|
|
|
ILOG("GPU_GLES: DeviceLost");
|
2013-08-08 06:27:29 +00:00
|
|
|
// Should only be executed on the GL thread.
|
|
|
|
|
2012-12-25 14:28:34 +00:00
|
|
|
// Simply drop all caches and textures.
|
2013-08-04 22:15:50 +00:00
|
|
|
// FBOs appear to survive? Or no?
|
2013-10-09 14:08:36 +00:00
|
|
|
// TransformDraw has registered as a GfxResourceHolder.
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->ClearCache(false);
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->Clear(false);
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_.Clear(false);
|
2014-03-30 13:37:51 +00:00
|
|
|
depalShaderCache_.Clear();
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->DeviceLost();
|
2016-09-11 03:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_GLES::DeviceRestore() {
|
|
|
|
ILOG("GPU_GLES: DeviceRestore");
|
2014-06-15 22:19:49 +00:00
|
|
|
|
2017-01-23 21:06:30 +00:00
|
|
|
UpdateCmdInfo();
|
2014-06-15 22:19:49 +00:00
|
|
|
UpdateVsyncInterval(true);
|
2012-12-25 14:28:34 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ReinitializeInternal() {
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->Clear(true);
|
2014-06-28 19:29:09 +00:00
|
|
|
depalShaderCache_.Clear();
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->DestroyAllFBOs(true);
|
|
|
|
framebufferManagerGL_->Resized();
|
2014-06-28 19:29:09 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::InitClearInternal() {
|
2013-08-27 14:31:50 +00:00
|
|
|
bool useNonBufferedRendering = g_Config.iRenderingMode == FB_NON_BUFFERED_MODE;
|
|
|
|
if (useNonBufferedRendering) {
|
2013-02-22 21:14:17 +00:00
|
|
|
glstate.depthWrite.set(GL_TRUE);
|
|
|
|
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
2012-11-20 09:59:23 +00:00
|
|
|
glClearColor(0,0,0,1);
|
2013-01-14 18:26:10 +00:00
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
|
2012-11-20 09:59:23 +00:00
|
|
|
}
|
2013-01-06 22:23:36 +00:00
|
|
|
glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::DumpNextFrame() {
|
2012-12-26 23:18:45 +00:00
|
|
|
dumpNextFrame_ = true;
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::BeginFrame() {
|
2013-08-08 06:59:32 +00:00
|
|
|
ScheduleEvent(GPU_EVENT_BEGIN_FRAME);
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
inline void GPU_GLES::UpdateVsyncInterval(bool force) {
|
2013-10-27 13:09:46 +00:00
|
|
|
#ifdef _WIN32
|
2013-08-06 15:08:57 +00:00
|
|
|
int desiredVSyncInterval = g_Config.bVSync ? 1 : 0;
|
2014-06-15 22:19:49 +00:00
|
|
|
if (PSP_CoreParameter().unthrottle) {
|
2013-06-16 21:45:06 +00:00
|
|
|
desiredVSyncInterval = 0;
|
2014-06-15 22:19:49 +00:00
|
|
|
}
|
|
|
|
if (PSP_CoreParameter().fpsLimit == 1) {
|
|
|
|
// For an alternative speed that is a clean factor of 60, the user probably still wants vsync.
|
|
|
|
if (g_Config.iFpsLimit == 0 || (g_Config.iFpsLimit != 15 && g_Config.iFpsLimit != 30 && g_Config.iFpsLimit != 60)) {
|
|
|
|
desiredVSyncInterval = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (desiredVSyncInterval != lastVsync_ || force) {
|
2013-08-24 09:53:54 +00:00
|
|
|
// Disabled EXT_swap_control_tear for now, it never seems to settle at the correct timing
|
|
|
|
// so it just keeps tearing. Not what I hoped for...
|
2014-06-15 22:19:49 +00:00
|
|
|
//if (gl_extensions.EXT_swap_control_tear) {
|
|
|
|
// // See http://developer.download.nvidia.com/opengl/specs/WGL_EXT_swap_control_tear.txt
|
2014-03-25 00:15:41 +00:00
|
|
|
// glstate.SetVSyncInterval(-desiredVSyncInterval);
|
|
|
|
//} else {
|
2015-12-31 15:59:40 +00:00
|
|
|
gfxCtx_->SwapInterval(desiredVSyncInterval);
|
2014-03-25 00:15:41 +00:00
|
|
|
//}
|
2013-06-16 21:45:06 +00:00
|
|
|
lastVsync_ = desiredVSyncInterval;
|
|
|
|
}
|
2013-10-27 13:09:46 +00:00
|
|
|
#endif
|
2014-06-15 22:19:49 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::UpdateCmdInfo() {
|
2014-06-29 04:51:25 +00:00
|
|
|
if (g_Config.bSoftwareSkinning) {
|
|
|
|
cmdInfo_[GE_CMD_VERTEXTYPE].flags &= ~FLAG_FLUSHBEFOREONCHANGE;
|
2016-04-10 08:21:48 +00:00
|
|
|
cmdInfo_[GE_CMD_VERTEXTYPE].func = &GPU_GLES::Execute_VertexTypeSkinning;
|
2014-06-29 04:51:25 +00:00
|
|
|
} else {
|
|
|
|
cmdInfo_[GE_CMD_VERTEXTYPE].flags |= FLAG_FLUSHBEFOREONCHANGE;
|
2016-04-10 08:21:48 +00:00
|
|
|
cmdInfo_[GE_CMD_VERTEXTYPE].func = &GPU_GLES::Execute_VertexType;
|
2014-06-29 04:51:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ReapplyGfxStateInternal() {
|
|
|
|
drawEngine_.RestoreVAO();
|
2015-09-06 10:23:14 +00:00
|
|
|
glstate.Restore();
|
|
|
|
GPUCommon::ReapplyGfxStateInternal();
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::BeginFrameInternal() {
|
2014-06-29 04:37:41 +00:00
|
|
|
if (resized_) {
|
2015-09-05 22:13:46 +00:00
|
|
|
CheckGPUFeatures();
|
2014-06-29 04:51:25 +00:00
|
|
|
UpdateCmdInfo();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Resized();
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->NotifyConfigChanged();
|
2014-06-29 04:37:41 +00:00
|
|
|
}
|
2014-06-15 22:19:49 +00:00
|
|
|
UpdateVsyncInterval(resized_);
|
|
|
|
resized_ = false;
|
2013-06-16 21:45:06 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->StartFrame();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.DecimateTrackedVertexArrays();
|
|
|
|
drawEngine_.DecimateBuffers();
|
2014-05-31 20:08:17 +00:00
|
|
|
depalShaderCache_.Decimate();
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_.Decimate();
|
2012-11-22 22:07:15 +00:00
|
|
|
|
2012-12-26 23:18:45 +00:00
|
|
|
if (dumpNextFrame_) {
|
|
|
|
NOTICE_LOG(G3D, "DUMPING THIS FRAME");
|
|
|
|
dumpThisFrame_ = true;
|
|
|
|
dumpNextFrame_ = false;
|
|
|
|
} else if (dumpThisFrame_) {
|
|
|
|
dumpThisFrame_ = false;
|
|
|
|
}
|
2016-01-17 19:29:34 +00:00
|
|
|
|
2016-01-17 16:11:51 +00:00
|
|
|
// Save the cache from time to time. TODO: How often?
|
2016-01-17 21:11:28 +00:00
|
|
|
if (!shaderCachePath_.empty() && (gpuStats.numFlips & 1023) == 0) {
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->Save(shaderCachePath_);
|
2016-01-17 20:35:24 +00:00
|
|
|
}
|
2016-01-17 16:11:51 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->DirtyShader();
|
2012-12-25 14:28:34 +00:00
|
|
|
|
|
|
|
// Not sure if this is really needed.
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALL_UNIFORMS);
|
2012-12-25 14:28:34 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->BeginFrame();
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
|
2013-09-22 07:18:46 +00:00
|
|
|
host->GPUNotifyDisplay(framebuf, stride, format);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->SetDisplayFramebuffer(framebuf, stride, format);
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::FramebufferDirty() {
|
2014-12-21 00:11:19 +00:00
|
|
|
if (ThreadEnabled()) {
|
2013-08-14 19:43:40 +00:00
|
|
|
// Allow it to process fully before deciding if it's dirty.
|
|
|
|
SyncThread();
|
|
|
|
}
|
2013-08-11 01:45:07 +00:00
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
VirtualFramebuffer *vfb = framebufferManagerGL_->GetDisplayVFB();
|
2013-08-15 23:00:26 +00:00
|
|
|
if (vfb) {
|
|
|
|
bool dirty = vfb->dirtyAfterDisplay;
|
|
|
|
vfb->dirtyAfterDisplay = false;
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::FramebufferReallyDirty() {
|
2014-12-21 00:11:19 +00:00
|
|
|
if (ThreadEnabled()) {
|
2013-08-15 23:00:26 +00:00
|
|
|
// Allow it to process fully before deciding if it's dirty.
|
|
|
|
SyncThread();
|
|
|
|
}
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
VirtualFramebuffer *vfb = framebufferManagerGL_->GetDisplayVFB();
|
2013-08-15 23:00:26 +00:00
|
|
|
if (vfb) {
|
|
|
|
bool dirty = vfb->reallyDirtyAfterDisplay;
|
|
|
|
vfb->reallyDirtyAfterDisplay = false;
|
|
|
|
return dirty;
|
|
|
|
}
|
2013-03-03 12:00:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::CopyDisplayToOutputInternal() {
|
2014-06-11 07:28:28 +00:00
|
|
|
// Flush anything left over.
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->RebindFramebuffer();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2014-06-11 07:28:28 +00:00
|
|
|
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->DirtyLastShader();
|
2014-06-23 04:03:33 +00:00
|
|
|
|
2013-04-02 22:28:09 +00:00
|
|
|
glstate.depthWrite.set(GL_TRUE);
|
|
|
|
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->CopyDisplayToOutput();
|
|
|
|
framebufferManagerGL_->EndFrame();
|
2012-11-19 22:29:14 +00:00
|
|
|
|
2013-07-26 22:44:16 +00:00
|
|
|
// If buffered, discard the depth buffer of the backbuffer. Don't even know if we need one.
|
|
|
|
#if 0
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
if (gl_extensions.EXT_discard_framebuffer && g_Config.iRenderingMode != 0) {
|
|
|
|
GLenum attachments[] = {GL_DEPTH_EXT, GL_STENCIL_EXT};
|
|
|
|
glDiscardFramebufferEXT(GL_FRAMEBUFFER, 2, attachments);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-01-24 08:31:36 +00:00
|
|
|
// Wait, why?
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
2013-08-23 12:22:26 +00:00
|
|
|
// Maybe should write this in ASM...
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::FastRunLoop(DisplayList &list) {
|
2015-05-25 22:39:27 +00:00
|
|
|
PROFILE_THIS_SCOPE("gpuloop");
|
2014-04-17 08:36:24 +00:00
|
|
|
const CommandInfo *cmdInfo = cmdInfo_;
|
2014-12-06 10:21:07 +00:00
|
|
|
int dc = downcount;
|
|
|
|
for (; dc > 0; --dc) {
|
2013-11-07 00:34:43 +00:00
|
|
|
// We know that display list PCs have the upper nibble == 0 - no need to mask the pointer
|
|
|
|
const u32 op = *(const u32 *)(Memory::base + list.pc);
|
2013-11-06 15:50:16 +00:00
|
|
|
const u32 cmd = op >> 24;
|
2014-04-17 08:36:24 +00:00
|
|
|
const CommandInfo info = cmdInfo[cmd];
|
|
|
|
const u8 cmdFlags = info.flags; // If we stashed the cmdFlags in the top bits of the cmdmem, we could get away with one table lookup instead of two
|
2013-11-06 15:50:16 +00:00
|
|
|
const u32 diff = op ^ gstate.cmdmem[cmd];
|
2013-08-15 23:00:26 +00:00
|
|
|
// Inlined CheckFlushOp here to get rid of the dumpThisFrame_ check.
|
2013-08-23 11:35:23 +00:00
|
|
|
if ((cmdFlags & FLAG_FLUSHBEFORE) || (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE))) {
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-08-23 11:35:23 +00:00
|
|
|
}
|
2013-11-10 10:18:58 +00:00
|
|
|
gstate.cmdmem[cmd] = op; // TODO: no need to write if diff==0...
|
2014-04-13 17:23:21 +00:00
|
|
|
if ((cmdFlags & FLAG_EXECUTE) || (diff && (cmdFlags & FLAG_EXECUTEONCHANGE))) {
|
2014-12-06 10:21:07 +00:00
|
|
|
downcount = dc;
|
2014-04-17 08:36:24 +00:00
|
|
|
(this->*info.func)(op, diff);
|
2014-12-06 10:21:07 +00:00
|
|
|
dc = downcount;
|
2013-11-07 00:34:43 +00:00
|
|
|
}
|
2013-04-28 21:23:30 +00:00
|
|
|
list.pc += 4;
|
|
|
|
}
|
2014-12-06 10:21:07 +00:00
|
|
|
downcount = 0;
|
2013-04-28 21:23:30 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::FinishDeferred() {
|
2015-03-15 01:11:00 +00:00
|
|
|
// This finishes reading any vertex data that is pending.
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.FinishDeferred();
|
2015-03-15 01:11:00 +00:00
|
|
|
}
|
2014-12-06 10:21:07 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
inline void GPU_GLES::CheckFlushOp(int cmd, u32 diff) {
|
2014-04-17 08:36:24 +00:00
|
|
|
const u8 cmdFlags = cmdInfo_[cmd].flags;
|
2013-08-23 11:35:23 +00:00
|
|
|
if ((cmdFlags & FLAG_FLUSHBEFORE) || (diff && (cmdFlags & FLAG_FLUSHBEFOREONCHANGE))) {
|
2013-01-20 12:15:46 +00:00
|
|
|
if (dumpThisFrame_) {
|
2013-09-07 20:02:55 +00:00
|
|
|
NOTICE_LOG(G3D, "================ FLUSH ================");
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::PreExecuteOp(u32 op, u32 diff) {
|
2013-08-06 17:08:38 +00:00
|
|
|
CheckFlushOp(op >> 24, diff);
|
2013-04-28 21:23:30 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ExecuteOp(u32 op, u32 diff) {
|
2014-04-13 17:23:21 +00:00
|
|
|
const u8 cmd = op >> 24;
|
2014-04-17 08:36:24 +00:00
|
|
|
const CommandInfo info = cmdInfo_[cmd];
|
|
|
|
const u8 cmdFlags = info.flags;
|
2014-04-13 17:23:21 +00:00
|
|
|
if ((cmdFlags & FLAG_EXECUTE) || (diff && (cmdFlags & FLAG_EXECUTEONCHANGE))) {
|
2014-04-17 08:36:24 +00:00
|
|
|
(this->*info.func)(op, diff);
|
2014-04-13 17:23:21 +00:00
|
|
|
}
|
2013-11-06 15:50:16 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Vaddr(u32 op, u32 diff) {
|
2014-04-16 15:01:56 +00:00
|
|
|
gstate_c.vertexAddr = gstate_c.getRelativeAddress(op & 0x00FFFFFF);
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Iaddr(u32 op, u32 diff) {
|
2014-04-16 15:01:56 +00:00
|
|
|
gstate_c.indexAddr = gstate_c.getRelativeAddress(op & 0x00FFFFFF);
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Prim(u32 op, u32 diff) {
|
2014-04-16 15:01:56 +00:00
|
|
|
// This drives all drawing. All other state we just buffer up, then we apply it only
|
|
|
|
// when it's time to draw. As most PSP games set state redundantly ALL THE TIME, this is a huge optimization.
|
|
|
|
|
|
|
|
u32 data = op & 0xFFFFFF;
|
|
|
|
u32 count = data & 0xFFFF;
|
2016-04-10 20:11:55 +00:00
|
|
|
// Upper bits are ignored.
|
|
|
|
GEPrimitiveType prim = static_cast<GEPrimitiveType>((data >> 16) & 7);
|
2014-04-16 15:01:56 +00:00
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though.
|
|
|
|
|
|
|
|
if (gstate.isAntiAliasEnabled()) {
|
|
|
|
// Discard AA lines in DOA
|
|
|
|
if (prim == GE_PRIM_LINE_STRIP)
|
|
|
|
return;
|
|
|
|
// Discard AA lines in Summon Night 5
|
|
|
|
if ((prim == GE_PRIM_LINES) && gstate.isSkinningEnabled())
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-03 19:05:08 +00:00
|
|
|
// This also makes skipping drawing very effective.
|
2017-01-23 22:25:09 +00:00
|
|
|
framebufferManagerGL_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
|
2014-04-16 15:01:56 +00:00
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.SetupVertexDecoder(gstate.vertType);
|
2014-04-16 15:01:56 +00:00
|
|
|
// Rough estimate, not sure what's correct.
|
2017-01-23 20:00:44 +00:00
|
|
|
cyclesExecuted += EstimatePerVertexCost() * count;
|
2014-04-16 15:01:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
|
|
|
void *inds = 0;
|
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef MOBILE_DEVICE
|
|
|
|
if (prim > GE_PRIM_RECTANGLES) {
|
|
|
|
ERROR_LOG_REPORT_ONCE(reportPrim, G3D, "Unexpected prim type: %d", prim);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-05-05 01:24:49 +00:00
|
|
|
int bytesRead = 0;
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.SubmitPrim(verts, inds, prim, count, gstate.vertType, &bytesRead);
|
2014-04-16 15:01:56 +00:00
|
|
|
|
2017-01-23 20:00:44 +00:00
|
|
|
int vertexCost = EstimatePerVertexCost();
|
2014-04-16 15:01:56 +00:00
|
|
|
gpuStats.vertexGPUCycles += vertexCost * count;
|
|
|
|
cyclesExecuted += vertexCost * count;
|
|
|
|
|
|
|
|
// After drawing, we advance the vertexAddr (when non indexed) or indexAddr (when indexed).
|
|
|
|
// Some games rely on this, they don't bother reloading VADDR and IADDR.
|
2014-05-05 01:24:49 +00:00
|
|
|
// The VADDR/IADDR registers are NOT updated.
|
2016-04-10 20:07:08 +00:00
|
|
|
AdvanceVerts(gstate.vertType, count, bytesRead);
|
2014-04-16 15:01:56 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_VertexType(u32 op, u32 diff) {
|
2014-06-29 04:37:41 +00:00
|
|
|
if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK)) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-06-29 04:37:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_VertexTypeSkinning(u32 op, u32 diff) {
|
2014-06-29 04:37:41 +00:00
|
|
|
// Don't flush when weight count changes, unless morph is enabled.
|
|
|
|
if ((diff & ~GE_VTYPE_WEIGHTCOUNT_MASK) || (op & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
|
|
|
// Restore and flush
|
|
|
|
gstate.vertType ^= diff;
|
|
|
|
Flush();
|
|
|
|
gstate.vertType ^= diff;
|
2014-04-16 15:01:56 +00:00
|
|
|
if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK))
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2015-05-17 04:49:25 +00:00
|
|
|
// In this case, we may be doing weights and morphs.
|
|
|
|
// Update any bone matrix uniforms so it uses them correctly.
|
|
|
|
if ((op & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(gstate_c.deferredVertTypeDirty);
|
2015-05-17 04:49:25 +00:00
|
|
|
gstate_c.deferredVertTypeDirty = 0;
|
|
|
|
}
|
2014-04-16 15:01:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-08 18:37:21 +00:00
|
|
|
void GPU_GLES::Execute_Bezier(u32 op, u32 diff) {
|
|
|
|
// This also make skipping drawing very effective.
|
2017-01-23 22:25:09 +00:00
|
|
|
framebufferManagerGL_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
|
2017-01-08 18:37:21 +00:00
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
|
|
|
// TODO: Should this eat some cycles? Probably yes. Not sure if important.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
|
|
|
void *indices = NULL;
|
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Bezier + morph: %i", (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT);
|
|
|
|
}
|
|
|
|
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Bezier + skinning: %i", vertTypeGetNumBoneWeights(gstate.vertType));
|
|
|
|
}
|
|
|
|
|
|
|
|
GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType();
|
|
|
|
int bz_ucount = op & 0xFF;
|
|
|
|
int bz_vcount = (op >> 8) & 0xFF;
|
|
|
|
bool computeNormals = gstate.isLightingEnabled();
|
|
|
|
bool patchFacing = gstate.patchfacing & 1;
|
|
|
|
|
|
|
|
if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
|
|
|
|
gstate_c.bezier = true;
|
|
|
|
if (gstate_c.bezier_count_u != bz_ucount) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_BEZIERCOUNTU);
|
2017-01-08 18:37:21 +00:00
|
|
|
gstate_c.bezier_count_u = bz_ucount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int bytesRead = 0;
|
|
|
|
drawEngine_.SubmitBezier(control_points, indices, gstate.getPatchDivisionU(), gstate.getPatchDivisionV(), bz_ucount, bz_vcount, patchPrim, computeNormals, patchFacing, gstate.vertType, &bytesRead);
|
|
|
|
|
|
|
|
gstate_c.bezier = false;
|
|
|
|
|
|
|
|
// After drawing, we advance pointers - see SubmitPrim which does the same.
|
|
|
|
int count = bz_ucount * bz_vcount;
|
|
|
|
AdvanceVerts(gstate.vertType, count, bytesRead);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GPU_GLES::Execute_Spline(u32 op, u32 diff) {
|
|
|
|
// This also make skipping drawing very effective.
|
2017-01-23 22:25:09 +00:00
|
|
|
framebufferManagerGL_->SetRenderFrameBuffer(gstate_c.IsDirty(DIRTY_FRAMEBUF), gstate_c.skipDrawReason);
|
2017-01-08 18:37:21 +00:00
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
|
|
|
// TODO: Should this eat some cycles? Probably yes. Not sure if important.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
|
|
|
void *indices = NULL;
|
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Spline + morph: %i", (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT);
|
|
|
|
}
|
|
|
|
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Spline + skinning: %i", vertTypeGetNumBoneWeights(gstate.vertType));
|
|
|
|
}
|
|
|
|
|
|
|
|
int sp_ucount = op & 0xFF;
|
|
|
|
int sp_vcount = (op >> 8) & 0xFF;
|
|
|
|
int sp_utype = (op >> 16) & 0x3;
|
|
|
|
int sp_vtype = (op >> 18) & 0x3;
|
|
|
|
GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType();
|
|
|
|
bool computeNormals = gstate.isLightingEnabled();
|
|
|
|
bool patchFacing = gstate.patchfacing & 1;
|
|
|
|
u32 vertType = gstate.vertType;
|
|
|
|
|
|
|
|
if (g_Config.bHardwareTessellation && g_Config.bHardwareTransform && !g_Config.bSoftwareRendering) {
|
|
|
|
gstate_c.spline = true;
|
|
|
|
if (gstate_c.spline_count_u != sp_ucount) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_SPLINECOUNTU);
|
2017-01-08 18:37:21 +00:00
|
|
|
gstate_c.spline_count_u = sp_ucount;
|
|
|
|
}
|
|
|
|
if (gstate_c.spline_count_v != sp_vcount) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_SPLINECOUNTV);
|
2017-01-08 18:37:21 +00:00
|
|
|
gstate_c.spline_count_v = sp_vcount;
|
|
|
|
}
|
|
|
|
if (gstate_c.spline_type_u != sp_utype) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_SPLINETYPEU);
|
2017-01-08 18:37:21 +00:00
|
|
|
gstate_c.spline_type_u = sp_utype;
|
|
|
|
}
|
|
|
|
if (gstate_c.spline_type_v != sp_vtype) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_SPLINETYPEV);
|
2017-01-08 18:37:21 +00:00
|
|
|
gstate_c.spline_type_v = sp_vtype;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int bytesRead = 0;
|
|
|
|
drawEngine_.SubmitSpline(control_points, indices, gstate.getPatchDivisionU(), gstate.getPatchDivisionV(), sp_ucount, sp_vcount, sp_utype, sp_vtype, patchPrim, computeNormals, patchFacing, vertType, &bytesRead);
|
|
|
|
|
|
|
|
gstate_c.spline = false;
|
|
|
|
|
|
|
|
// After drawing, we advance pointers - see SubmitPrim which does the same.
|
|
|
|
int count = sp_ucount * sp_vcount;
|
|
|
|
AdvanceVerts(gstate.vertType, count, bytesRead);
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Region(u32 op, u32 diff) {
|
2017-01-23 22:25:09 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FRAMEBUF);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Scissor(u32 op, u32 diff) {
|
2017-01-23 22:25:09 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FRAMEBUF);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-18 05:41:37 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_FramebufType(u32 op, u32 diff) {
|
2017-01-23 22:25:09 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FRAMEBUF);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 15:29:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_ViewportType(u32 op, u32 diff) {
|
2017-01-23 22:25:09 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FRAMEBUF);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2015-08-26 16:46:55 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_ViewportZType(u32 op, u32 diff) {
|
2017-01-23 22:25:09 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FRAMEBUF);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
|
|
|
gstate_c.Dirty(DIRTY_DEPTHRANGE);
|
2014-04-18 05:49:09 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexScaleU(u32 op, u32 diff) {
|
2014-04-17 15:26:38 +00:00
|
|
|
gstate_c.uv.uScale = getFloat24(op);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexScaleV(u32 op, u32 diff) {
|
2014-04-17 15:26:38 +00:00
|
|
|
gstate_c.uv.vScale = getFloat24(op);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexOffsetU(u32 op, u32 diff) {
|
2014-04-17 15:26:38 +00:00
|
|
|
gstate_c.uv.uOff = getFloat24(op);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexOffsetV(u32 op, u32 diff) {
|
2014-04-17 15:26:38 +00:00
|
|
|
gstate_c.uv.vOff = getFloat24(op);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 15:26:38 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexAddr0(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexAddrN(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexBufw0(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexBufwN(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexSize0(u32 op, u32 diff) {
|
2014-04-17 07:22:32 +00:00
|
|
|
// Render to texture may have overridden the width/height.
|
|
|
|
// Don't reset it unless the size is different / the texture has changed.
|
2017-01-24 08:41:38 +00:00
|
|
|
if (diff || gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS)) {
|
2014-04-17 07:22:32 +00:00
|
|
|
gstate_c.curTextureWidth = gstate.getTextureWidth(0);
|
|
|
|
gstate_c.curTextureHeight = gstate.getTextureHeight(0);
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-17 07:22:32 +00:00
|
|
|
// We will need to reset the texture now.
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexSizeN(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexFormat(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2014-04-17 15:29:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexMapMode(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
2014-04-18 05:41:37 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexParamType(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-18 05:41:37 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexEnvColor(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXENV);
|
2014-04-17 15:29:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_TexLevel(u32 op, u32 diff) {
|
2014-04-22 05:47:44 +00:00
|
|
|
// I had hoped that this would let us avoid excessively flushing in Gran Turismo, but not so,
|
|
|
|
// as the game switches rapidly between modes 0 and 1.
|
|
|
|
/*
|
|
|
|
if (gstate.getTexLevelMode() == GE_TEXLEVEL_MODE_CONST) {
|
|
|
|
gstate.texlevel ^= diff;
|
|
|
|
Flush();
|
|
|
|
gstate.texlevel ^= diff;
|
|
|
|
}
|
|
|
|
*/
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-22 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_LoadClut(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->LoadClut(gstate.getClutAddress(), gstate.getClutLoadBytes());
|
2014-04-17 15:29:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_ClutFormat(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-04-18 05:57:02 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Ambient(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_AMBIENT);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_MaterialDiffuse(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_MATDIFFUSE);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_MaterialEmissive(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_MATEMISSIVE);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_MaterialAmbient(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_MATAMBIENTALPHA);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_MaterialSpecular(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_MATSPECULAR);
|
2014-04-17 07:22:32 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Light0Param(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_LIGHT0);
|
2014-04-22 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Light1Param(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_LIGHT1);
|
2014-04-22 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Light2Param(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_LIGHT2);
|
2014-04-22 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Light3Param(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_LIGHT3);
|
2014-04-22 05:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_FogColor(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FOGCOLOR);
|
2014-04-22 05:56:54 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_FogCoef(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_FOGCOEF);
|
2014-04-22 05:56:54 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_ColorTestMask(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALPHACOLORMASK);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_AlphaTest(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALPHACOLORREF | DIRTY_ALPHACOLORMASK);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_StencilTest(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_STENCILREPLACEVALUE);
|
2014-04-18 05:51:45 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_ColorRef(u32 op, u32 diff) {
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_ALPHACOLORREF);
|
2014-04-17 15:18:43 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::Execute_Generic(u32 op, u32 diff) {
|
2012-11-01 15:19:01 +00:00
|
|
|
u32 cmd = op >> 24;
|
|
|
|
u32 data = op & 0xFFFFFF;
|
|
|
|
|
|
|
|
// Handle control and drawing commands here directly. The others we delegate.
|
2012-12-28 18:33:26 +00:00
|
|
|
switch (cmd) {
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_BASE:
|
|
|
|
break;
|
|
|
|
|
2013-02-02 22:47:35 +00:00
|
|
|
case GE_CMD_VADDR:
|
2014-04-16 15:01:56 +00:00
|
|
|
Execute_Vaddr(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_IADDR:
|
2014-04-16 15:01:56 +00:00
|
|
|
Execute_Iaddr(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PRIM:
|
2014-04-16 15:01:56 +00:00
|
|
|
Execute_Prim(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BEZIER:
|
2014-04-17 15:09:44 +00:00
|
|
|
Execute_Bezier(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_SPLINE:
|
2014-04-17 15:09:44 +00:00
|
|
|
Execute_Spline(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BOUNDINGBOX:
|
2014-04-18 05:51:45 +00:00
|
|
|
Execute_BoundingBox(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VERTEXTYPE:
|
2014-04-16 15:01:56 +00:00
|
|
|
Execute_VertexType(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_REGION1:
|
|
|
|
case GE_CMD_REGION2:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_Region(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_CLIPENABLE:
|
|
|
|
//we always clip, this is opengl
|
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_CULLFACEENABLE:
|
2013-02-24 05:48:09 +00:00
|
|
|
case GE_CMD_CULL:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_TEXTUREMAPENABLE:
|
2014-04-13 20:01:18 +00:00
|
|
|
// Don't need to dirty the texture here, already dirtied at list start/etc.
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LIGHTINGENABLE:
|
|
|
|
break;
|
|
|
|
|
2013-01-14 19:43:18 +00:00
|
|
|
case GE_CMD_FOGCOLOR:
|
2014-04-22 05:56:54 +00:00
|
|
|
Execute_FogColor(op, diff);
|
2013-01-14 19:43:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_FOG1:
|
|
|
|
case GE_CMD_FOG2:
|
2014-04-22 05:56:54 +00:00
|
|
|
Execute_FogCoef(op, diff);
|
2013-01-14 19:43:18 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_FOGENABLE:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_DITHERENABLE:
|
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_OFFSETX:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_OFFSETY:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXSCALEU:
|
2014-04-17 15:26:38 +00:00
|
|
|
Execute_TexScaleU(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXSCALEV:
|
2014-04-17 15:26:38 +00:00
|
|
|
Execute_TexScaleV(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXOFFSETU:
|
2014-04-17 15:26:38 +00:00
|
|
|
Execute_TexOffsetU(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXOFFSETV:
|
2014-04-17 15:26:38 +00:00
|
|
|
Execute_TexOffsetV(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_SCISSOR1:
|
|
|
|
case GE_CMD_SCISSOR2:
|
2014-04-18 05:41:37 +00:00
|
|
|
Execute_Scissor(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-14 21:33:55 +00:00
|
|
|
///
|
2012-11-24 23:15:21 +00:00
|
|
|
case GE_CMD_MINZ:
|
|
|
|
case GE_CMD_MAXZ:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_FRAMEBUFPTR:
|
|
|
|
case GE_CMD_FRAMEBUFWIDTH:
|
|
|
|
case GE_CMD_FRAMEBUFPIXFORMAT:
|
2014-04-16 15:01:56 +00:00
|
|
|
Execute_FramebufType(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXADDR0:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_TexAddr0(op, diff);
|
2014-04-13 17:25:14 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_TEXADDR1:
|
|
|
|
case GE_CMD_TEXADDR2:
|
|
|
|
case GE_CMD_TEXADDR3:
|
|
|
|
case GE_CMD_TEXADDR4:
|
|
|
|
case GE_CMD_TEXADDR5:
|
|
|
|
case GE_CMD_TEXADDR6:
|
|
|
|
case GE_CMD_TEXADDR7:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_TexAddrN(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXBUFWIDTH0:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_TexBufw0(op, diff);
|
2014-04-13 21:02:00 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_TEXBUFWIDTH1:
|
|
|
|
case GE_CMD_TEXBUFWIDTH2:
|
|
|
|
case GE_CMD_TEXBUFWIDTH3:
|
|
|
|
case GE_CMD_TEXBUFWIDTH4:
|
|
|
|
case GE_CMD_TEXBUFWIDTH5:
|
|
|
|
case GE_CMD_TEXBUFWIDTH6:
|
|
|
|
case GE_CMD_TEXBUFWIDTH7:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_TexBufwN(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-02-23 18:05:06 +00:00
|
|
|
case GE_CMD_CLUTFORMAT:
|
2014-04-18 05:57:02 +00:00
|
|
|
Execute_ClutFormat(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-11-11 23:18:49 +00:00
|
|
|
case GE_CMD_CLUTADDR:
|
|
|
|
case GE_CMD_CLUTADDRUPPER:
|
|
|
|
// Hm, LOADCLUT actually changes the CLUT so no need to dirty here.
|
|
|
|
break;
|
|
|
|
|
2013-05-11 22:45:17 +00:00
|
|
|
case GE_CMD_LOADCLUT:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_LoadClut(op, diff);
|
2013-05-11 22:45:17 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-19 14:14:41 +00:00
|
|
|
case GE_CMD_TEXMAPMODE:
|
2014-04-18 05:41:37 +00:00
|
|
|
Execute_TexMapMode(op, diff);
|
2013-07-09 23:22:15 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-19 14:14:41 +00:00
|
|
|
case GE_CMD_TEXSHADELS:
|
|
|
|
break;
|
|
|
|
|
2012-11-19 22:29:14 +00:00
|
|
|
case GE_CMD_TRANSFERSRC:
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_TRANSFERSRCW:
|
2012-11-19 22:29:14 +00:00
|
|
|
case GE_CMD_TRANSFERDST:
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_TRANSFERDSTW:
|
|
|
|
case GE_CMD_TRANSFERSRCPOS:
|
|
|
|
case GE_CMD_TRANSFERDSTPOS:
|
2012-12-28 18:33:26 +00:00
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
case GE_CMD_TRANSFERSIZE:
|
2012-12-28 18:33:26 +00:00
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2017-01-23 15:57:16 +00:00
|
|
|
case GE_CMD_TRANSFERSTART:
|
2014-04-17 15:05:16 +00:00
|
|
|
Execute_BlockTransferStart(op, diff);
|
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
case GE_CMD_TEXSIZE0:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_TexSize0(op, diff);
|
2014-04-13 17:25:14 +00:00
|
|
|
break;
|
2013-11-10 10:18:58 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_TEXSIZE1:
|
|
|
|
case GE_CMD_TEXSIZE2:
|
|
|
|
case GE_CMD_TEXSIZE3:
|
|
|
|
case GE_CMD_TEXSIZE4:
|
|
|
|
case GE_CMD_TEXSIZE5:
|
|
|
|
case GE_CMD_TEXSIZE6:
|
|
|
|
case GE_CMD_TEXSIZE7:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_TexSizeN(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_ZBUFPTR:
|
|
|
|
case GE_CMD_ZBUFWIDTH:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_AMBIENTCOLOR:
|
|
|
|
case GE_CMD_AMBIENTALPHA:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_Ambient(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MATERIALDIFFUSE:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_MaterialDiffuse(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MATERIALEMISSIVE:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_MaterialEmissive(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-04-20 14:46:25 +00:00
|
|
|
case GE_CMD_MATERIALAMBIENT:
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_MATERIALALPHA:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_MaterialAmbient(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-04-20 14:46:25 +00:00
|
|
|
case GE_CMD_MATERIALSPECULAR:
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_MATERIALSPECULARCOEF:
|
2014-04-17 07:22:32 +00:00
|
|
|
Execute_MaterialSpecular(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LIGHTTYPE0:
|
|
|
|
case GE_CMD_LIGHTTYPE1:
|
|
|
|
case GE_CMD_LIGHTTYPE2:
|
|
|
|
case GE_CMD_LIGHTTYPE3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LX0:case GE_CMD_LY0:case GE_CMD_LZ0:
|
|
|
|
case GE_CMD_LDX0:case GE_CMD_LDY0:case GE_CMD_LDZ0:
|
|
|
|
case GE_CMD_LKA0:case GE_CMD_LKB0:case GE_CMD_LKC0:
|
2014-04-18 12:30:18 +00:00
|
|
|
case GE_CMD_LKS0: // spot coef ("conv")
|
|
|
|
case GE_CMD_LKO0: // light angle ("cutoff")
|
|
|
|
case GE_CMD_LAC0:
|
|
|
|
case GE_CMD_LDC0:
|
|
|
|
case GE_CMD_LSC0:
|
2014-04-22 05:47:44 +00:00
|
|
|
Execute_Light0Param(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
2014-04-18 12:30:18 +00:00
|
|
|
case GE_CMD_LX1:case GE_CMD_LY1:case GE_CMD_LZ1:
|
|
|
|
case GE_CMD_LDX1:case GE_CMD_LDY1:case GE_CMD_LDZ1:
|
|
|
|
case GE_CMD_LKA1:case GE_CMD_LKB1:case GE_CMD_LKC1:
|
2013-04-09 16:25:22 +00:00
|
|
|
case GE_CMD_LKS1:
|
|
|
|
case GE_CMD_LKO1:
|
2014-04-18 12:30:18 +00:00
|
|
|
case GE_CMD_LAC1:
|
|
|
|
case GE_CMD_LDC1:
|
|
|
|
case GE_CMD_LSC1:
|
2014-04-22 05:47:44 +00:00
|
|
|
Execute_Light1Param(op, diff);
|
2014-04-18 12:30:18 +00:00
|
|
|
break;
|
|
|
|
case GE_CMD_LX2:case GE_CMD_LY2:case GE_CMD_LZ2:
|
|
|
|
case GE_CMD_LDX2:case GE_CMD_LDY2:case GE_CMD_LDZ2:
|
|
|
|
case GE_CMD_LKA2:case GE_CMD_LKB2:case GE_CMD_LKC2:
|
|
|
|
case GE_CMD_LKS2:
|
2013-04-09 16:25:22 +00:00
|
|
|
case GE_CMD_LKO2:
|
2014-04-18 12:30:18 +00:00
|
|
|
case GE_CMD_LAC2:
|
|
|
|
case GE_CMD_LDC2:
|
|
|
|
case GE_CMD_LSC2:
|
2014-04-22 05:47:44 +00:00
|
|
|
Execute_Light2Param(op, diff);
|
2013-04-09 16:25:22 +00:00
|
|
|
break;
|
2014-04-18 12:30:18 +00:00
|
|
|
case GE_CMD_LX3:case GE_CMD_LY3:case GE_CMD_LZ3:
|
|
|
|
case GE_CMD_LDX3:case GE_CMD_LDY3:case GE_CMD_LDZ3:
|
|
|
|
case GE_CMD_LKA3:case GE_CMD_LKB3:case GE_CMD_LKC3:
|
|
|
|
case GE_CMD_LKS3:
|
|
|
|
case GE_CMD_LKO3:
|
|
|
|
case GE_CMD_LAC3:
|
|
|
|
case GE_CMD_LDC3:
|
|
|
|
case GE_CMD_LSC3:
|
2014-04-22 05:47:44 +00:00
|
|
|
Execute_Light3Param(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2015-11-04 21:03:29 +00:00
|
|
|
case GE_CMD_VIEWPORTXSCALE:
|
|
|
|
case GE_CMD_VIEWPORTYSCALE:
|
|
|
|
case GE_CMD_VIEWPORTXCENTER:
|
|
|
|
case GE_CMD_VIEWPORTYCENTER:
|
|
|
|
case GE_CMD_VIEWPORTZSCALE:
|
|
|
|
case GE_CMD_VIEWPORTZCENTER:
|
2014-04-18 05:49:09 +00:00
|
|
|
Execute_ViewportType(op, diff);
|
2013-08-23 11:35:23 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_LIGHTENABLE0:
|
|
|
|
case GE_CMD_LIGHTENABLE1:
|
|
|
|
case GE_CMD_LIGHTENABLE2:
|
|
|
|
case GE_CMD_LIGHTENABLE3:
|
|
|
|
break;
|
2012-12-28 18:33:26 +00:00
|
|
|
|
2013-02-02 12:40:26 +00:00
|
|
|
case GE_CMD_SHADEMODE:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PATCHDIVISION:
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_PATCHPRIMITIVE:
|
|
|
|
case GE_CMD_PATCHFACING:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_MATERIALUPDATE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// CLEARING
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
case GE_CMD_CLEARMODE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// ALPHA BLENDING
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
case GE_CMD_ALPHABLENDENABLE:
|
|
|
|
case GE_CMD_BLENDMODE:
|
2014-05-11 16:51:35 +00:00
|
|
|
break;
|
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_BLENDFIXEDA:
|
|
|
|
case GE_CMD_BLENDFIXEDB:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_ALPHATESTENABLE:
|
2013-01-14 19:43:18 +00:00
|
|
|
case GE_CMD_COLORTESTENABLE:
|
2013-02-24 21:59:53 +00:00
|
|
|
// They are done in the fragment shader.
|
|
|
|
break;
|
|
|
|
|
2013-02-24 05:48:09 +00:00
|
|
|
case GE_CMD_COLORTEST:
|
2014-04-22 05:53:19 +00:00
|
|
|
break;
|
|
|
|
|
2013-02-24 05:48:09 +00:00
|
|
|
case GE_CMD_COLORTESTMASK:
|
2014-04-22 05:53:19 +00:00
|
|
|
Execute_ColorTestMask(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
case GE_CMD_ALPHATEST:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_AlphaTest(op, diff);
|
2014-04-13 17:25:14 +00:00
|
|
|
break;
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-05-11 05:51:23 +00:00
|
|
|
case GE_CMD_COLORREF:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_ColorRef(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXENVCOLOR:
|
2014-04-17 15:18:43 +00:00
|
|
|
Execute_TexEnvColor(op, diff);
|
2012-12-01 22:38:18 +00:00
|
|
|
break;
|
2012-12-28 18:33:26 +00:00
|
|
|
|
|
|
|
case GE_CMD_TEXFUNC:
|
2012-11-28 12:45:22 +00:00
|
|
|
case GE_CMD_TEXFLUSH:
|
2013-09-23 12:49:24 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-23 15:08:06 +00:00
|
|
|
case GE_CMD_TEXFORMAT:
|
2014-04-17 15:29:44 +00:00
|
|
|
Execute_TexFormat(op, diff);
|
2014-04-13 21:02:00 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXMODE:
|
2013-09-23 12:49:24 +00:00
|
|
|
case GE_CMD_TEXFILTER:
|
2012-11-28 12:45:22 +00:00
|
|
|
case GE_CMD_TEXWRAP:
|
2014-04-18 05:41:37 +00:00
|
|
|
Execute_TexParamType(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
2012-12-28 18:33:26 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
//////////////////////////////////////////////////////////////////
|
2013-12-26 03:18:16 +00:00
|
|
|
// DEPTH TESTING
|
2012-11-01 15:19:01 +00:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
case GE_CMD_ZTESTENABLE:
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_ZTEST:
|
2013-10-08 01:29:51 +00:00
|
|
|
case GE_CMD_ZWRITEDISABLE:
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MORPHWEIGHT0:
|
|
|
|
case GE_CMD_MORPHWEIGHT1:
|
|
|
|
case GE_CMD_MORPHWEIGHT2:
|
|
|
|
case GE_CMD_MORPHWEIGHT3:
|
|
|
|
case GE_CMD_MORPHWEIGHT4:
|
|
|
|
case GE_CMD_MORPHWEIGHT5:
|
|
|
|
case GE_CMD_MORPHWEIGHT6:
|
|
|
|
case GE_CMD_MORPHWEIGHT7:
|
2014-04-13 17:25:14 +00:00
|
|
|
gstate_c.morphWeights[cmd - GE_CMD_MORPHWEIGHT0] = getFloat24(data);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
2012-12-01 22:38:18 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
case GE_CMD_DITH0:
|
|
|
|
case GE_CMD_DITH1:
|
|
|
|
case GE_CMD_DITH2:
|
|
|
|
case GE_CMD_DITH3:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_WORLDMATRIXNUMBER:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_WorldMtxNum(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_WORLDMATRIXDATA:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_WorldMtxData(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VIEWMATRIXNUMBER:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_ViewMtxNum(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VIEWMATRIXDATA:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_ViewMtxData(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PROJMATRIXNUMBER:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_ProjMtxNum(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PROJMATRIXDATA:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_ProjMtxData(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TGENMATRIXNUMBER:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_TgenMtxNum(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TGENMATRIXDATA:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_TgenMtxData(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BONEMATRIXNUMBER:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_BoneMtxNum(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BONEMATRIXDATA:
|
2014-04-17 15:00:01 +00:00
|
|
|
Execute_BoneMtxData(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2014-02-08 18:29:22 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-05-12 17:15:13 +00:00
|
|
|
case GE_CMD_ANTIALIASENABLE:
|
|
|
|
if (data != 0)
|
2013-05-12 19:00:21 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(antiAlias, G3D, "Unsupported antialias enabled: %06x", data);
|
2013-05-12 17:15:13 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXLODSLOPE:
|
|
|
|
if (data != 0)
|
2013-05-12 19:00:21 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(texLodSlope, G3D, "Unsupported texture lod slope: %06x", data);
|
2013-05-12 17:15:13 +00:00
|
|
|
break;
|
2014-02-08 18:29:22 +00:00
|
|
|
#endif
|
2013-05-12 17:15:13 +00:00
|
|
|
|
|
|
|
case GE_CMD_TEXLEVEL:
|
2014-04-18 14:00:53 +00:00
|
|
|
Execute_TexLevel(op, diff);
|
2013-05-12 17:15:13 +00:00
|
|
|
break;
|
|
|
|
|
2013-12-26 03:18:16 +00:00
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
// STENCIL TESTING
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
2013-11-18 15:51:10 +00:00
|
|
|
case GE_CMD_STENCILTEST:
|
2014-04-18 05:51:45 +00:00
|
|
|
Execute_StencilTest(op, diff);
|
2013-12-02 23:09:48 +00:00
|
|
|
break;
|
2013-12-26 03:18:16 +00:00
|
|
|
|
|
|
|
case GE_CMD_STENCILTESTENABLE:
|
2013-11-18 15:51:10 +00:00
|
|
|
case GE_CMD_STENCILOP:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MASKRGB:
|
|
|
|
case GE_CMD_MASKALPHA:
|
|
|
|
break;
|
|
|
|
|
2013-11-28 09:01:22 +00:00
|
|
|
case GE_CMD_REVERSENORMAL:
|
|
|
|
break;
|
|
|
|
|
2014-04-26 14:58:51 +00:00
|
|
|
case GE_CMD_VSCX:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vscx, G3D, "Unsupported Vertex Screen Coordinate X : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VSCY:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vscy, G3D, "Unsupported Vertex Screen Coordinate Y : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VSCZ:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vscz, G3D, "Unsupported Vertex Screen Coordinate Z : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VTCS:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vtcs, G3D, "Unsupported Vertex Texture Coordinate S : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VTCT:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vtct, G3D, "Unsupported Vertex Texture Coordinate T : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VTCQ:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vtcq, G3D, "Unsupported Vertex Texture Coordinate Q : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VCV:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vcv, G3D, "Unsupported Vertex Color Value : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VAP:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vap, G3D, "Unsupported Vertex Alpha and Primitive : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VFC:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vfc, G3D, "Unsupported Vertex Fog Coefficient : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VSCV:
|
|
|
|
if (data != 0)
|
2014-05-06 07:26:52 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(vscv, G3D, "Unsupported Vertex Secondary Color Value : %06x", data);
|
2014-04-26 14:58:51 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
2013-09-20 06:30:33 +00:00
|
|
|
case GE_CMD_UNKNOWN_03:
|
|
|
|
case GE_CMD_UNKNOWN_0D:
|
|
|
|
case GE_CMD_UNKNOWN_11:
|
|
|
|
case GE_CMD_UNKNOWN_29:
|
|
|
|
case GE_CMD_UNKNOWN_34:
|
|
|
|
case GE_CMD_UNKNOWN_35:
|
|
|
|
case GE_CMD_UNKNOWN_39:
|
|
|
|
case GE_CMD_UNKNOWN_4E:
|
|
|
|
case GE_CMD_UNKNOWN_4F:
|
|
|
|
case GE_CMD_UNKNOWN_52:
|
|
|
|
case GE_CMD_UNKNOWN_59:
|
|
|
|
case GE_CMD_UNKNOWN_5A:
|
|
|
|
case GE_CMD_UNKNOWN_B6:
|
|
|
|
case GE_CMD_UNKNOWN_B7:
|
|
|
|
case GE_CMD_UNKNOWN_D1:
|
|
|
|
case GE_CMD_UNKNOWN_ED:
|
2013-10-08 07:34:17 +00:00
|
|
|
case GE_CMD_UNKNOWN_EF:
|
|
|
|
case GE_CMD_UNKNOWN_FA:
|
|
|
|
case GE_CMD_UNKNOWN_FB:
|
|
|
|
case GE_CMD_UNKNOWN_FC:
|
|
|
|
case GE_CMD_UNKNOWN_FD:
|
|
|
|
case GE_CMD_UNKNOWN_FE:
|
2013-09-23 04:00:56 +00:00
|
|
|
if (data != 0)
|
|
|
|
WARN_LOG_REPORT_ONCE(unknowncmd, G3D, "Unknown GE command : %08x ", op);
|
2013-09-20 06:30:33 +00:00
|
|
|
break;
|
2013-10-25 05:03:10 +00:00
|
|
|
case GE_CMD_UNKNOWN_FF:
|
|
|
|
// This is hit in quite a few games, supposedly it is a no-op.
|
|
|
|
// Might be used for debugging or something?
|
|
|
|
break;
|
2013-09-20 06:30:33 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
default:
|
2013-04-01 06:02:46 +00:00
|
|
|
GPUCommon::ExecuteOp(op, diff);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
|
2016-03-31 08:17:02 +00:00
|
|
|
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
|
|
|
|
snprintf(buffer, bufsize - 1,
|
|
|
|
"DL processing time: %0.2f ms\n"
|
|
|
|
"Draw calls: %i, flushes %i\n"
|
|
|
|
"Cached Draw calls: %i\n"
|
|
|
|
"Num Tracked Vertex Arrays: %i\n"
|
|
|
|
"GPU cycles executed: %d (%f per vertex)\n"
|
|
|
|
"Commands per call level: %i %i %i %i\n"
|
|
|
|
"Vertices submitted: %i\n"
|
|
|
|
"Cached, Uncached Vertices Drawn: %i, %i\n"
|
|
|
|
"FBOs active: %i\n"
|
|
|
|
"Textures active: %i, decoded: %i invalidated: %i\n"
|
2016-04-02 08:28:38 +00:00
|
|
|
"Vertex, Fragment, Programs loaded: %i, %i, %i\n",
|
2016-03-31 08:17:02 +00:00
|
|
|
gpuStats.msProcessingDisplayLists * 1000.0f,
|
|
|
|
gpuStats.numDrawCalls,
|
|
|
|
gpuStats.numFlushes,
|
|
|
|
gpuStats.numCachedDrawCalls,
|
|
|
|
gpuStats.numTrackedVertexArrays,
|
|
|
|
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
|
|
|
|
vertexAverageCycles,
|
|
|
|
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
|
|
|
|
gpuStats.numVertsSubmitted,
|
|
|
|
gpuStats.numCachedVertsDrawn,
|
|
|
|
gpuStats.numUncachedVertsDrawn,
|
2016-12-21 17:07:17 +00:00
|
|
|
(int)framebufferManagerGL_->NumVFBs(),
|
|
|
|
(int)textureCacheGL_->NumLoadedTextures(),
|
2016-03-31 08:17:02 +00:00
|
|
|
gpuStats.numTexturesDecoded,
|
|
|
|
gpuStats.numTextureInvalidations,
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->NumVertexShaders(),
|
|
|
|
shaderManagerGL_->NumFragmentShaders(),
|
|
|
|
shaderManagerGL_->NumPrograms());
|
2012-11-26 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ClearCacheNextFrame() {
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->ClearNextFrame();
|
2013-04-30 15:20:28 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::ClearShaderCache() {
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->ClearCache(true);
|
2013-01-26 23:15:39 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::CleanupBeforeUI() {
|
2014-06-23 04:42:29 +00:00
|
|
|
// Clear any enabled vertex arrays.
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->DirtyLastShader();
|
2015-02-04 16:28:31 +00:00
|
|
|
glstate.arrayBuffer.bind(0);
|
|
|
|
glstate.elementArrayBuffer.bind(0);
|
2014-06-23 04:42:29 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::vector<FramebufferInfo> GPU_GLES::GetFramebufferList() {
|
2016-12-21 17:07:17 +00:00
|
|
|
return framebufferManagerGL_->GetFramebufferList();
|
2013-02-17 00:06:06 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
void GPU_GLES::DoState(PointerWrap &p) {
|
2013-01-26 23:15:39 +00:00
|
|
|
GPUCommon::DoState(p);
|
|
|
|
|
2013-09-29 20:19:32 +00:00
|
|
|
// TODO: Some of these things may not be necessary.
|
|
|
|
// None of these are necessary when saving.
|
2013-11-15 15:30:55 +00:00
|
|
|
// In Freeze-Frame mode, we don't want to do any of this.
|
|
|
|
if (p.mode == p.MODE_READ && !PSP_CoreParameter().frozen) {
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->Clear(true);
|
2014-03-30 13:37:51 +00:00
|
|
|
depalShaderCache_.Clear();
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.ClearTrackedVertexArrays();
|
2013-01-26 23:15:39 +00:00
|
|
|
|
2017-01-24 08:41:38 +00:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
|
2016-12-21 17:07:17 +00:00
|
|
|
framebufferManagerGL_->DestroyAllFBOs(true);
|
2017-01-23 19:48:23 +00:00
|
|
|
shaderManagerGL_->ClearCache(true);
|
2013-09-29 20:19:32 +00:00
|
|
|
}
|
2012-12-29 20:21:56 +00:00
|
|
|
}
|
2013-09-23 02:03:31 +00:00
|
|
|
|
2016-09-25 23:31:38 +00:00
|
|
|
bool GPU_GLES::GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) {
|
2016-12-21 17:07:17 +00:00
|
|
|
u32 fb_address = type == GPU_DBG_FRAMEBUF_RENDER ? gstate.getFrameBufRawAddress() : framebufferManagerGL_->DisplayFramebufAddr();
|
|
|
|
int fb_stride = type == GPU_DBG_FRAMEBUF_RENDER ? gstate.FrameBufStride() : framebufferManagerGL_->DisplayFramebufStride();
|
|
|
|
GEBufferFormat format = type == GPU_DBG_FRAMEBUF_RENDER ? gstate.FrameBufFormat() : framebufferManagerGL_->DisplayFramebufFormat();
|
|
|
|
return framebufferManagerGL_->GetFramebuffer(fb_address, fb_stride, format, buffer, maxRes);
|
2013-09-23 02:03:31 +00:00
|
|
|
}
|
2013-09-28 04:53:42 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::GetCurrentDepthbuffer(GPUDebugBuffer &buffer) {
|
2015-08-05 10:13:14 +00:00
|
|
|
u32 fb_address = gstate.getFrameBufRawAddress();
|
|
|
|
int fb_stride = gstate.FrameBufStride();
|
|
|
|
|
|
|
|
u32 z_address = gstate.getDepthBufRawAddress();
|
|
|
|
int z_stride = gstate.DepthBufStride();
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
return framebufferManagerGL_->GetDepthbuffer(fb_address, fb_stride, z_address, z_stride, buffer);
|
2013-09-28 09:14:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::GetCurrentStencilbuffer(GPUDebugBuffer &buffer) {
|
2015-08-05 10:13:14 +00:00
|
|
|
u32 fb_address = gstate.getFrameBufRawAddress();
|
|
|
|
int fb_stride = gstate.FrameBufStride();
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
return framebufferManagerGL_->GetStencilbuffer(fb_address, fb_stride, buffer);
|
2013-09-28 09:14:27 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::GetCurrentTexture(GPUDebugBuffer &buffer, int level) {
|
2013-09-28 04:53:42 +00:00
|
|
|
if (!gstate.isTextureMapEnabled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef USING_GLES2
|
2014-06-15 16:30:37 +00:00
|
|
|
GPUgstate saved;
|
|
|
|
if (level != 0) {
|
|
|
|
saved = gstate;
|
|
|
|
|
|
|
|
// The way we set textures is a bit complex. Let's just override level 0.
|
|
|
|
gstate.texsize[0] = gstate.texsize[level];
|
|
|
|
gstate.texaddr[0] = gstate.texaddr[level];
|
|
|
|
gstate.texbufwidth[0] = gstate.texbufwidth[level];
|
|
|
|
}
|
|
|
|
|
2016-12-21 17:07:17 +00:00
|
|
|
textureCacheGL_->SetTexture(true);
|
|
|
|
textureCacheGL_->ApplyTexture();
|
2014-06-15 16:30:37 +00:00
|
|
|
int w = gstate.getTextureWidth(level);
|
|
|
|
int h = gstate.getTextureHeight(level);
|
2013-09-28 04:53:42 +00:00
|
|
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
|
|
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
|
|
|
|
2014-06-15 16:30:37 +00:00
|
|
|
if (level != 0) {
|
|
|
|
gstate = saved;
|
|
|
|
}
|
|
|
|
|
2015-10-31 22:59:23 +00:00
|
|
|
buffer.Allocate(w, h, GE_FORMAT_8888, false);
|
2013-09-28 04:53:42 +00:00
|
|
|
glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
|
|
|
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer.GetData());
|
|
|
|
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2013-10-01 06:04:48 +00:00
|
|
|
}
|
2013-10-14 03:47:52 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::GetCurrentClut(GPUDebugBuffer &buffer) {
|
2016-12-21 17:07:17 +00:00
|
|
|
return textureCacheGL_->GetCurrentClutBuffer(buffer);
|
2016-01-10 17:25:19 +00:00
|
|
|
}
|
|
|
|
|
2016-09-25 23:35:43 +00:00
|
|
|
bool GPU_GLES::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
|
2017-01-21 21:16:30 +00:00
|
|
|
return FramebufferManagerGLES::GetOutputFramebuffer(buffer);
|
2014-12-20 16:31:56 +00:00
|
|
|
}
|
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
|
|
|
|
return drawEngine_.GetCurrentSimpleVertices(count, vertices, indices);
|
2013-10-14 03:47:52 +00:00
|
|
|
}
|
2013-12-01 02:39:16 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
bool GPU_GLES::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
|
|
|
if (drawEngine_.IsCodePtrVertexDecoder(ptr)) {
|
2013-12-01 02:39:16 +00:00
|
|
|
name = "VertexDecoderJit";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2015-10-14 15:45:21 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::vector<std::string> GPU_GLES::DebugGetShaderIDs(DebugShaderType type) {
|
2015-10-21 21:06:32 +00:00
|
|
|
if (type == SHADER_TYPE_VERTEXLOADER) {
|
2016-04-10 08:21:48 +00:00
|
|
|
return drawEngine_.DebugGetVertexLoaderIDs();
|
2015-10-21 21:06:32 +00:00
|
|
|
} else {
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerGL_->DebugGetShaderIDs(type);
|
2015-10-21 21:06:32 +00:00
|
|
|
}
|
2015-10-14 15:45:21 +00:00
|
|
|
}
|
2015-10-21 21:06:32 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
std::string GPU_GLES::DebugGetShaderString(std::string id, DebugShaderType type, DebugShaderStringType stringType) {
|
2015-10-21 21:06:32 +00:00
|
|
|
if (type == SHADER_TYPE_VERTEXLOADER) {
|
2016-04-10 08:21:48 +00:00
|
|
|
return drawEngine_.DebugGetVertexLoaderString(id, stringType);
|
2015-10-21 21:06:32 +00:00
|
|
|
} else {
|
2017-01-23 19:48:23 +00:00
|
|
|
return shaderManagerGL_->DebugGetShaderString(id, type, stringType);
|
2015-10-21 21:06:32 +00:00
|
|
|
}
|
2015-10-14 15:45:21 +00:00
|
|
|
}
|