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"
|
2013-07-26 22:44:16 +00:00
|
|
|
#include "gfx_es2/gl_state.h"
|
|
|
|
|
2013-12-29 22:28:31 +00:00
|
|
|
#include "Common/ChunkFile.h"
|
|
|
|
|
2013-12-14 22:54:05 +00:00
|
|
|
#include "Core/Debugger/Breakpoints.h"
|
2013-01-30 20:09:53 +00:00
|
|
|
#include "Core/MemMap.h"
|
|
|
|
#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"
|
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"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "GPU/GLES/ShaderManager.h"
|
|
|
|
#include "GPU/GLES/GLES_GPU.h"
|
|
|
|
#include "GPU/GLES/Framebuffer.h"
|
|
|
|
#include "GPU/GLES/TransformPipeline.h"
|
|
|
|
#include "GPU/GLES/TextureCache.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
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
|
|
|
|
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.
|
|
|
|
FLAG_EXECUTEONCHANGE = 8, // unused for now. not sure if checking for this will be more expensive than doing it.
|
2013-11-10 10:18:58 +00:00
|
|
|
FLAG_ANY_EXECUTE = 4 | 8,
|
2013-02-11 18:03:11 +00:00
|
|
|
};
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
struct CommandTableEntry {
|
|
|
|
u8 cmd;
|
|
|
|
u8 flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const CommandTableEntry commandTable[] = {
|
|
|
|
// Changes that dirty the framebuffer
|
|
|
|
{GE_CMD_FRAMEBUFPTR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_FRAMEBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_FRAMEBUFPIXFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_ZBUFPTR, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ZBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// Changes that dirty uniforms
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_FOGCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_FOG1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_FOG2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-09-14 21:33:55 +00:00
|
|
|
// Should these maybe flush?
|
|
|
|
{GE_CMD_MINZ, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_MAXZ, FLAG_FLUSHBEFOREONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changes that dirty texture scaling.
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXMAPMODE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSCALEU, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSCALEV, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXOFFSETU, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXOFFSETV, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
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.
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXSIZE0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXSIZE7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXADDR7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH4, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH5, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH6, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXBUFWIDTH7, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_CLUTADDR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_CLUTADDRUPPER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_CLUTFORMAT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
|
|
|
|
// These affect the fragment shader so need flushing.
|
|
|
|
{GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE},
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_SHADEMODE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_TEXFUNC, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_COLORTEST, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ALPHATESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_COLORTESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_COLORTESTMASK, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
|
|
|
|
// These change the vertex shader so need flushing.
|
|
|
|
{GE_CMD_REVERSENORMAL, FLAG_FLUSHBEFOREONCHANGE}, // TODO: This one is actually processed during vertex decoding which is wrong.
|
|
|
|
{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},
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXFILTER, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXWRAP, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Uniform changes
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_ALPHATEST, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_COLORREF, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_TEXENVCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
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},
|
2013-12-02 23:55:09 +00:00
|
|
|
{GE_CMD_STENCILTEST, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_STENCILTESTENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_ALPHABLENDENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_BLENDMODE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_BLENDFIXEDA, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_BLENDFIXEDB, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{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},
|
|
|
|
#ifndef USING_GLES2
|
|
|
|
{GE_CMD_LOGICOP, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
{GE_CMD_LOGICOPENABLE, FLAG_FLUSHBEFOREONCHANGE},
|
|
|
|
#else
|
|
|
|
{GE_CMD_LOGICOP, 0},
|
|
|
|
{GE_CMD_LOGICOPENABLE, 0},
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 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.
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_VIEWPORTX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_VIEWPORTY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_VIEWPORTX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_VIEWPORTY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_VIEWPORTZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_VIEWPORTZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-10-08 01:29:51 +00:00
|
|
|
// Region
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_REGION1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_REGION2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-10-08 01:29:51 +00:00
|
|
|
|
|
|
|
// Scissor
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_SCISSOR1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_SCISSOR2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
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...
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_AMBIENTCOLOR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_AMBIENTALPHA, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALDIFFUSE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALEMISSIVE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALAMBIENT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALALPHA, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALSPECULAR, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_MATERIALSPECULARCOEF, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// These precompute a value. not sure if worth it. Also dirty uniforms, which could be table-ized to avoid execute.
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_LX0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LY0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LZ0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LX3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LY3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LZ3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
|
|
|
|
{GE_CMD_LDX0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDY0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDZ0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDX1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDY1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDZ1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDX2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDY2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDZ2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDX3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDY3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDZ3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
|
|
|
|
{GE_CMD_LKA0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKB0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKA1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKB1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKA2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKB2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKA3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKB3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
|
|
|
|
{GE_CMD_LKS0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKS1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKS2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKS3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
|
|
|
|
{GE_CMD_LKO0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKO1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKO2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LKO3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
|
|
|
|
{GE_CMD_LAC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LSC0, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LAC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LSC1, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LAC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LSC2, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LAC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LDC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
|
|
|
{GE_CMD_LSC3, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Ignored commands
|
|
|
|
{GE_CMD_CLIPENABLE, 0},
|
|
|
|
{GE_CMD_TEXFLUSH, 0},
|
|
|
|
{GE_CMD_TEXLODSLOPE, 0},
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_TEXLEVEL, FLAG_EXECUTEONCHANGE}, // we don't support this anyway, no need to flush.
|
2013-08-23 11:35:23 +00:00
|
|
|
{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.
|
|
|
|
{GE_CMD_OFFSETADDR, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_ORIGIN, FLAG_EXECUTE}, // Really?
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_PRIM, FLAG_EXECUTE},
|
2013-08-23 12:22:26 +00:00
|
|
|
{GE_CMD_JUMP, FLAG_EXECUTE},
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_CALL, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_RET, FLAG_EXECUTE},
|
2013-08-23 12:22:26 +00:00
|
|
|
{GE_CMD_END, FLAG_EXECUTE}, // Flush?
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_VADDR, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_IADDR, FLAG_EXECUTE},
|
2013-08-23 12:22:26 +00:00
|
|
|
{GE_CMD_BJUMP, FLAG_EXECUTE}, // EXECUTE
|
|
|
|
{GE_CMD_BOUNDINGBOX, FLAG_EXECUTE}, // + FLUSHBEFORE when we implement
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
// Changing the vertex type requires us to flush.
|
2013-11-10 10:18:58 +00:00
|
|
|
{GE_CMD_VERTEXTYPE, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTEONCHANGE},
|
2013-08-23 11:35:23 +00:00
|
|
|
|
|
|
|
{GE_CMD_BEZIER, FLAG_FLUSHBEFORE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_SPLINE, FLAG_FLUSHBEFORE | FLAG_EXECUTE},
|
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...
|
|
|
|
{GE_CMD_LOADCLUT, FLAG_FLUSHBEFOREONCHANGE | FLAG_EXECUTE},
|
|
|
|
{GE_CMD_TRANSFERSTART, FLAG_FLUSHBEFORE | FLAG_EXECUTE},
|
|
|
|
|
|
|
|
// 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.
|
2013-08-23 11:35:23 +00:00
|
|
|
{GE_CMD_WORLDMATRIXNUMBER, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_WORLDMATRIXDATA, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VIEWMATRIXNUMBER, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_VIEWMATRIXDATA, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_PROJMATRIXNUMBER, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_PROJMATRIXDATA, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_TGENMATRIXNUMBER, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_TGENMATRIXDATA, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_BONEMATRIXNUMBER, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_BONEMATRIXDATA, 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_F0, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F1, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F2, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F3, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F4, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F5, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F6, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F7, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F8, FLAG_EXECUTE},
|
|
|
|
{GE_CMD_UNKNOWN_F9, 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},
|
|
|
|
{GE_CMD_UNKNOWN_FF, FLAG_EXECUTE},
|
2012-12-21 20:49:09 +00:00
|
|
|
};
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-01-28 23:48:13 +00:00
|
|
|
GLES_GPU::GLES_GPU()
|
2013-06-16 21:45:06 +00:00
|
|
|
: resized_(false) {
|
2013-10-27 13:09:46 +00:00
|
|
|
#ifdef _WIN32
|
2013-08-06 15:08:57 +00:00
|
|
|
lastVsync_ = g_Config.bVSync ? 1 : 0;
|
2013-07-07 08:58:21 +00:00
|
|
|
if (gl_extensions.EXT_swap_control_tear) {
|
|
|
|
// See http://developer.download.nvidia.com/opengl/specs/WGL_EXT_swap_control_tear.txt
|
2013-07-20 14:03:52 +00:00
|
|
|
glstate.SetVSyncInterval(g_Config.bVSync ? -1 :0);
|
2013-07-07 08:58:21 +00:00
|
|
|
} else {
|
2013-07-20 14:03:52 +00:00
|
|
|
glstate.SetVSyncInterval(g_Config.bVSync ? 1 : 0);
|
2013-07-07 08:58:21 +00:00
|
|
|
}
|
2013-10-27 13:09:46 +00:00
|
|
|
#endif
|
2013-10-09 08:44:12 +00:00
|
|
|
|
2012-12-25 14:28:34 +00:00
|
|
|
shaderManager_ = new ShaderManager();
|
|
|
|
transformDraw_.SetShaderManager(shaderManager_);
|
2013-01-30 19:40:26 +00:00
|
|
|
transformDraw_.SetTextureCache(&textureCache_);
|
2013-01-31 23:18:23 +00:00
|
|
|
transformDraw_.SetFramebufferManager(&framebufferManager_);
|
|
|
|
framebufferManager_.SetTextureCache(&textureCache_);
|
2013-03-15 23:40:37 +00:00
|
|
|
framebufferManager_.SetShaderManager(shaderManager_);
|
2014-01-20 01:28:11 +00:00
|
|
|
textureCache_.SetFramebufferManager(&framebufferManager_);
|
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
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
// Sanity check commandFlags table - no dupes please
|
|
|
|
std::set<u8> dupeCheck;
|
|
|
|
commandFlags_ = new u8[256];
|
|
|
|
memset(commandFlags_, 0, 256 * sizeof(bool));
|
|
|
|
for (size_t i = 0; i < ARRAY_SIZE(commandTable); i++) {
|
|
|
|
u8 cmd = commandTable[i].cmd;
|
|
|
|
if (dupeCheck.find(cmd) != dupeCheck.end()) {
|
|
|
|
ERROR_LOG(G3D, "Command table Dupe: %02x (%i)", (int)cmd, (int)cmd);
|
|
|
|
} else {
|
|
|
|
dupeCheck.insert(cmd);
|
|
|
|
}
|
|
|
|
commandFlags_[cmd] |= commandTable[i].flags;
|
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
|
|
|
|
2013-10-09 08:44:12 +00:00
|
|
|
if (g_Config.bPrescaleUV) {
|
|
|
|
commandFlags_[GE_CMD_TEXSCALEU] &= ~FLAG_FLUSHBEFOREONCHANGE;
|
|
|
|
commandFlags_[GE_CMD_TEXSCALEV] &= ~FLAG_FLUSHBEFOREONCHANGE;
|
|
|
|
commandFlags_[GE_CMD_TEXOFFSETU] &= ~FLAG_FLUSHBEFOREONCHANGE;
|
|
|
|
commandFlags_[GE_CMD_TEXOFFSETV] &= ~FLAG_FLUSHBEFOREONCHANGE;
|
|
|
|
}
|
|
|
|
|
2013-11-10 12:18:52 +00:00
|
|
|
if (g_Config.bSoftwareSkinning) {
|
2013-11-10 15:05:34 +00:00
|
|
|
commandFlags_[GE_CMD_VERTEXTYPE] &= ~FLAG_FLUSHBEFOREONCHANGE;
|
2013-11-10 12:18:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-29 00:49:17 +00:00
|
|
|
BuildReportingInfo();
|
2012-11-20 09:59:23 +00:00
|
|
|
}
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
GLES_GPU::~GLES_GPU() {
|
2013-01-30 20:09:53 +00:00
|
|
|
framebufferManager_.DestroyAllFBOs();
|
2012-12-25 14:28:34 +00:00
|
|
|
shaderManager_->ClearCache(true);
|
|
|
|
delete shaderManager_;
|
2013-08-23 11:35:23 +00:00
|
|
|
delete [] commandFlags_;
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
void GLES_GPU::BuildReportingInfo() {
|
|
|
|
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);
|
|
|
|
const char *glExtensions = GetGLStringAlways(GL_EXTENSIONS);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2012-12-25 14:28:34 +00:00
|
|
|
void GLES_GPU::DeviceLost() {
|
2013-10-09 14:08:36 +00:00
|
|
|
ILOG("GLES_GPU: 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.
|
2012-12-25 14:28:34 +00:00
|
|
|
shaderManager_->ClearCache(false);
|
2013-01-30 19:40:26 +00:00
|
|
|
textureCache_.Clear(false);
|
2013-06-11 09:28:41 +00:00
|
|
|
framebufferManager_.DeviceLost();
|
2012-12-25 14:28:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
void GLES_GPU::InitClear() {
|
2013-08-08 06:59:32 +00:00
|
|
|
ScheduleEvent(GPU_EVENT_INIT_CLEAR);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::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
|
|
|
|
2012-12-26 23:18:45 +00:00
|
|
|
void GLES_GPU::DumpNextFrame() {
|
|
|
|
dumpNextFrame_ = true;
|
|
|
|
}
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
void GLES_GPU::BeginFrame() {
|
2013-08-08 06:59:32 +00:00
|
|
|
ScheduleEvent(GPU_EVENT_BEGIN_FRAME);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::BeginFrameInternal() {
|
2013-10-27 13:09:46 +00:00
|
|
|
#ifdef _WIN32
|
2013-06-16 21:45:06 +00:00
|
|
|
// Turn off vsync when unthrottled
|
2013-08-06 15:08:57 +00:00
|
|
|
int desiredVSyncInterval = g_Config.bVSync ? 1 : 0;
|
2013-07-11 19:51:45 +00:00
|
|
|
if ((PSP_CoreParameter().unthrottle) || (PSP_CoreParameter().fpsLimit == 1))
|
2013-06-16 21:45:06 +00:00
|
|
|
desiredVSyncInterval = 0;
|
|
|
|
if (desiredVSyncInterval != lastVsync_) {
|
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...
|
|
|
|
if (false && gl_extensions.EXT_swap_control_tear) {
|
2013-07-07 08:58:21 +00:00
|
|
|
// See http://developer.download.nvidia.com/opengl/specs/WGL_EXT_swap_control_tear.txt
|
|
|
|
glstate.SetVSyncInterval(-desiredVSyncInterval);
|
|
|
|
} else {
|
|
|
|
glstate.SetVSyncInterval(desiredVSyncInterval);
|
|
|
|
}
|
2013-06-16 21:45:06 +00:00
|
|
|
lastVsync_ = desiredVSyncInterval;
|
|
|
|
}
|
2013-10-27 13:09:46 +00:00
|
|
|
#endif
|
2013-06-16 21:45:06 +00:00
|
|
|
|
2013-01-30 19:40:26 +00:00
|
|
|
textureCache_.StartFrame();
|
2013-01-19 16:05:08 +00:00
|
|
|
transformDraw_.DecimateTrackedVertexArrays();
|
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;
|
|
|
|
}
|
2012-12-25 14:28:34 +00:00
|
|
|
shaderManager_->DirtyShader();
|
|
|
|
|
|
|
|
// Not sure if this is really needed.
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_ALL);
|
|
|
|
|
2013-01-30 20:09:53 +00:00
|
|
|
framebufferManager_.BeginFrame();
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-07-30 06:05:59 +00:00
|
|
|
void GLES_GPU::SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) {
|
2013-09-22 07:18:46 +00:00
|
|
|
host->GPUNotifyDisplay(framebuf, stride, format);
|
2013-01-30 20:09:53 +00:00
|
|
|
framebufferManager_.SetDisplayFramebuffer(framebuf, stride, format);
|
2012-11-19 20:23:29 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-03-03 12:00:21 +00:00
|
|
|
bool GLES_GPU::FramebufferDirty() {
|
2013-08-14 19:43:40 +00:00
|
|
|
if (g_Config.bSeparateCPUThread) {
|
|
|
|
// Allow it to process fully before deciding if it's dirty.
|
|
|
|
SyncThread();
|
|
|
|
}
|
2013-08-11 01:45:07 +00:00
|
|
|
|
2013-09-21 16:52:30 +00:00
|
|
|
VirtualFramebuffer *vfb = framebufferManager_.GetDisplayVFB();
|
2013-08-15 23:00:26 +00:00
|
|
|
if (vfb) {
|
|
|
|
bool dirty = vfb->dirtyAfterDisplay;
|
|
|
|
vfb->dirtyAfterDisplay = false;
|
|
|
|
return dirty;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GLES_GPU::FramebufferReallyDirty() {
|
|
|
|
if (g_Config.bSeparateCPUThread) {
|
|
|
|
// Allow it to process fully before deciding if it's dirty.
|
|
|
|
SyncThread();
|
|
|
|
}
|
|
|
|
|
2013-09-21 16:52:30 +00:00
|
|
|
VirtualFramebuffer *vfb = framebufferManager_.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;
|
|
|
|
}
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
void GLES_GPU::CopyDisplayToOutput() {
|
2013-08-08 06:59:32 +00:00
|
|
|
ScheduleEvent(GPU_EVENT_COPY_DISPLAY_TO_OUTPUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::CopyDisplayToOutputInternal() {
|
2013-04-02 22:28:09 +00:00
|
|
|
glstate.depthWrite.set(GL_TRUE);
|
|
|
|
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
transformDraw_.Flush();
|
2012-11-20 09:59:23 +00:00
|
|
|
|
2013-01-30 20:09:53 +00:00
|
|
|
framebufferManager_.CopyDisplayToOutput();
|
2013-03-03 12:00:21 +00:00
|
|
|
framebufferManager_.EndFrame();
|
2012-11-19 22:29:14 +00:00
|
|
|
|
2013-10-10 18:11:20 +00:00
|
|
|
shaderManager_->DirtyLastShader();
|
2013-04-07 21:31:04 +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
|
|
|
|
|
2012-11-19 23:31:19 +00:00
|
|
|
gstate_c.textureChanged = true;
|
2012-11-19 22:29:14 +00:00
|
|
|
}
|
|
|
|
|
2013-08-23 12:22:26 +00:00
|
|
|
// Maybe should write this in ASM...
|
2013-04-28 21:23:30 +00:00
|
|
|
void GLES_GPU::FastRunLoop(DisplayList &list) {
|
2013-11-06 15:50:16 +00:00
|
|
|
const u8 *commandFlags = commandFlags_;
|
2013-04-28 21:23:30 +00:00
|
|
|
for (; downcount > 0; --downcount) {
|
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;
|
2013-11-10 10:18:58 +00:00
|
|
|
const u8 cmdFlags = commandFlags[cmd]; // 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))) {
|
2013-08-15 23:00:26 +00:00
|
|
|
transformDraw_.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...
|
|
|
|
if (cmdFlags & FLAG_ANY_EXECUTE) { // (cmdFlags & FLAG_EXECUTE) || (diff && (cmdFlags & FLAG_EXECUTEONCHANGE))) {
|
2013-11-06 15:50:16 +00:00
|
|
|
ExecuteOpInternal(op, diff);
|
2013-11-07 00:34:43 +00:00
|
|
|
}
|
2013-04-28 21:23:30 +00:00
|
|
|
list.pc += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-08 06:59:32 +00:00
|
|
|
void GLES_GPU::ProcessEvent(GPUEvent ev) {
|
|
|
|
switch (ev.type) {
|
|
|
|
case GPU_EVENT_INIT_CLEAR:
|
|
|
|
InitClearInternal();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPU_EVENT_BEGIN_FRAME:
|
|
|
|
BeginFrameInternal();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPU_EVENT_COPY_DISPLAY_TO_OUTPUT:
|
|
|
|
CopyDisplayToOutputInternal();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GPU_EVENT_INVALIDATE_CACHE:
|
|
|
|
InvalidateCacheInternal(ev.invalidate_cache.addr, ev.invalidate_cache.size, ev.invalidate_cache.type);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2013-08-10 10:33:09 +00:00
|
|
|
GPUCommon::ProcessEvent(ev);
|
2013-08-08 06:59:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-06 17:08:38 +00:00
|
|
|
inline void GLES_GPU::CheckFlushOp(int cmd, u32 diff) {
|
2013-08-23 11:35:23 +00:00
|
|
|
u8 cmdFlags = commandFlags_[cmd];
|
|
|
|
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
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
transformDraw_.Flush();
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
2012-12-29 01:10:29 +00:00
|
|
|
}
|
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
void GLES_GPU::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
|
|
|
}
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
void GLES_GPU::ExecuteOp(u32 op, u32 diff) {
|
2013-11-06 15:50:16 +00:00
|
|
|
return ExecuteOpInternal(op, diff);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::ExecuteOpInternal(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:
|
|
|
|
gstate_c.vertexAddr = gstate_c.getRelativeAddress(data);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_IADDR:
|
2013-02-02 22:47:35 +00:00
|
|
|
gstate_c.indexAddr = gstate_c.getRelativeAddress(data);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PRIM:
|
|
|
|
{
|
2013-03-03 12:00:21 +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.
|
|
|
|
|
2013-04-20 18:20:03 +00:00
|
|
|
u32 count = data & 0xFFFF;
|
2013-08-25 17:51:06 +00:00
|
|
|
GEPrimitiveType prim = static_cast<GEPrimitiveType>(data >> 16);
|
2013-09-04 09:14:49 +00:00
|
|
|
|
|
|
|
if (count == 0)
|
|
|
|
break;
|
|
|
|
|
2013-08-21 18:42:51 +00:00
|
|
|
// Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though.
|
2013-08-29 14:30:47 +00:00
|
|
|
|
2013-09-20 06:41:52 +00:00
|
|
|
if (gstate.isAntiAliasEnabled()) {
|
|
|
|
// Discard AA lines in DOA
|
|
|
|
if (prim == GE_PRIM_LINE_STRIP)
|
|
|
|
break;
|
2013-12-16 12:44:13 +00:00
|
|
|
// Discard AA lines in Summon Night 5
|
|
|
|
if ((prim == GE_PRIM_LINES) && gstate.isSkinningEnabled())
|
2013-09-20 06:41:52 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-04-20 18:20:03 +00:00
|
|
|
|
2013-03-03 12:00:21 +00:00
|
|
|
// This also make skipping drawing very effective.
|
2013-01-30 20:09:53 +00:00
|
|
|
framebufferManager_.SetRenderFrameBuffer();
|
2013-09-20 06:41:52 +00:00
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
2013-04-20 18:20:03 +00:00
|
|
|
transformDraw_.SetupVertexDecoder(gstate.vertType);
|
|
|
|
// Rough estimate, not sure what's correct.
|
|
|
|
int vertexCost = transformDraw_.EstimatePerVertexCost();
|
|
|
|
cyclesExecuted += vertexCost * count;
|
2013-03-03 12:00:21 +00:00
|
|
|
return;
|
2013-04-20 18:20:03 +00:00
|
|
|
}
|
2012-12-28 18:33:26 +00:00
|
|
|
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
2013-08-24 18:19:35 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
2012-12-20 13:35:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-12-28 19:53:26 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
// TODO: Split this so that we can collect sequences of primitives, can greatly speed things up
|
|
|
|
// on platforms where draw calls are expensive like mobile and D3D
|
2013-11-08 06:59:20 +00:00
|
|
|
void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
2012-11-01 15:19:01 +00:00
|
|
|
void *inds = 0;
|
2012-12-28 18:33:26 +00:00
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
|
2013-08-24 18:19:35 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
|
2012-12-20 13:35:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-11-08 06:59:20 +00:00
|
|
|
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
2012-12-20 13:35:47 +00:00
|
|
|
}
|
2012-11-28 12:45:22 +00:00
|
|
|
|
2014-02-08 18:29:22 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-08-24 18:19:35 +00:00
|
|
|
if (prim > GE_PRIM_RECTANGLES) {
|
|
|
|
ERROR_LOG_REPORT_ONCE(reportPrim, G3D, "Unexpected prim type: %d", prim);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-11-28 12:45:22 +00:00
|
|
|
int bytesRead;
|
2013-11-14 13:03:03 +00:00
|
|
|
transformDraw_.SubmitPrim(verts, inds, prim, count, gstate.vertType, &bytesRead);
|
2013-04-20 18:20:03 +00:00
|
|
|
|
|
|
|
int vertexCost = transformDraw_.EstimatePerVertexCost();
|
2013-05-31 17:40:16 +00:00
|
|
|
gpuStats.vertexGPUCycles += vertexCost * count;
|
2013-04-20 18:20:03 +00:00
|
|
|
cyclesExecuted += vertexCost * count;
|
|
|
|
|
2012-12-28 19:53:26 +00:00
|
|
|
// 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.
|
|
|
|
// Q: Are these changed reflected in the real registers? Needs testing.
|
|
|
|
if (inds) {
|
|
|
|
int indexSize = 1;
|
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
|
|
|
|
indexSize = 2;
|
|
|
|
gstate_c.indexAddr += count * indexSize;
|
|
|
|
} else {
|
|
|
|
gstate_c.vertexAddr += bytesRead;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
// The arrow and other rotary items in Puzbob are bezier patches, strangely enough.
|
|
|
|
case GE_CMD_BEZIER:
|
|
|
|
{
|
2013-09-30 06:28:02 +00:00
|
|
|
// This also make skipping drawing very effective.
|
|
|
|
framebufferManager_.SetRenderFrameBuffer();
|
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
|
|
|
// TODO: Should this eat some cycles? Probably yes. Not sure if important.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-19 13:09:59 +00:00
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-08 06:59:20 +00:00
|
|
|
void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
2013-08-30 08:25:01 +00:00
|
|
|
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);
|
|
|
|
break;
|
|
|
|
}
|
2013-11-08 06:59:20 +00:00
|
|
|
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
2013-08-30 08:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gstate.getPatchPrimitiveType() != GE_PATCHPRIM_TRIANGLES) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Unsupported patch primitive %x", gstate.getPatchPrimitiveType());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-09-16 07:01:20 +00:00
|
|
|
if (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Bezier + morph: %i", (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT);
|
|
|
|
}
|
2013-09-21 21:37:14 +00:00
|
|
|
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Bezier + skinning: %i", vertTypeGetNumBoneWeights(gstate.vertType));
|
2013-09-16 07:01:20 +00:00
|
|
|
}
|
|
|
|
|
2013-09-23 13:55:07 +00:00
|
|
|
GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType();
|
2012-11-02 11:33:16 +00:00
|
|
|
int bz_ucount = data & 0xFF;
|
|
|
|
int bz_vcount = (data >> 8) & 0xFF;
|
2013-09-22 07:51:32 +00:00
|
|
|
transformDraw_.SubmitBezier(control_points, indices, bz_ucount, bz_vcount, patchPrim, gstate.vertType);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_SPLINE:
|
|
|
|
{
|
2013-09-30 06:28:02 +00:00
|
|
|
// This also make skipping drawing very effective.
|
|
|
|
framebufferManager_.SetRenderFrameBuffer();
|
|
|
|
if (gstate_c.skipDrawReason & (SKIPDRAW_SKIPFRAME | SKIPDRAW_NON_DISPLAYED_FB)) {
|
|
|
|
// TODO: Should this eat some cycles? Probably yes. Not sure if important.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-19 13:09:59 +00:00
|
|
|
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-11-08 06:59:20 +00:00
|
|
|
void *control_points = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
|
2013-08-23 13:35:02 +00:00
|
|
|
void *indices = NULL;
|
|
|
|
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
|
|
|
|
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
|
2013-08-24 17:20:31 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
|
2013-08-23 13:35:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-11-08 06:59:20 +00:00
|
|
|
indices = Memory::GetPointerUnchecked(gstate_c.indexAddr);
|
2013-08-23 13:35:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (gstate.getPatchPrimitiveType() != GE_PATCHPRIM_TRIANGLES) {
|
2013-08-24 17:51:17 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "Unsupported patch primitive %x", gstate.getPatchPrimitiveType());
|
2013-08-23 13:35:02 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-16 07:01:20 +00:00
|
|
|
|
|
|
|
if (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Spline + morph: %i", (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) >> GE_VTYPE_MORPHCOUNT_SHIFT);
|
|
|
|
}
|
2013-09-21 21:37:14 +00:00
|
|
|
if (vertTypeIsSkinningEnabled(gstate.vertType)) {
|
|
|
|
DEBUG_LOG_REPORT(G3D, "Spline + skinning: %i", vertTypeGetNumBoneWeights(gstate.vertType));
|
2013-09-16 07:01:20 +00:00
|
|
|
}
|
|
|
|
|
2012-11-02 11:33:16 +00:00
|
|
|
int sp_ucount = data & 0xFF;
|
|
|
|
int sp_vcount = (data >> 8) & 0xFF;
|
|
|
|
int sp_utype = (data >> 16) & 0x3;
|
|
|
|
int sp_vtype = (data >> 18) & 0x3;
|
2013-08-24 17:20:07 +00:00
|
|
|
GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType();
|
2013-08-22 22:26:16 +00:00
|
|
|
transformDraw_.SubmitSpline(control_points, indices, sp_ucount, sp_vcount, sp_utype, sp_vtype, patchPrim, gstate.vertType);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BOUNDINGBOX:
|
2013-10-05 21:03:16 +00:00
|
|
|
// Just resetting, nothing to bound.
|
|
|
|
if (data == 0) {
|
|
|
|
// TODO: Should this set the bboxResult? Let's set it true for now.
|
|
|
|
currentList->bboxResult = true;
|
|
|
|
break;
|
|
|
|
}
|
2013-11-12 15:47:29 +00:00
|
|
|
if (((data & 7) == 0) && data <= 64) { // Sanity check
|
2013-09-24 11:58:14 +00:00
|
|
|
void *control_points = Memory::GetPointer(gstate_c.vertexAddr);
|
|
|
|
if (gstate.vertType & GE_VTYPE_IDX_MASK) {
|
|
|
|
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Indexed bounding box data not supported.");
|
|
|
|
// Data seems invalid. Let's assume the box test passed.
|
|
|
|
currentList->bboxResult = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Test if the bounding box is within the drawing region.
|
|
|
|
currentList->bboxResult = transformDraw_.TestBoundingBox(control_points, data, gstate.vertType);
|
|
|
|
} else {
|
|
|
|
ERROR_LOG_REPORT_ONCE(boundingbox, G3D, "Bad bounding box data: %06x", data);
|
|
|
|
// Data seems invalid. Let's assume the box test passed.
|
|
|
|
currentList->bboxResult = true;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VERTEXTYPE:
|
2013-11-10 12:18:52 +00:00
|
|
|
if (diff) {
|
|
|
|
if (!g_Config.bSoftwareSkinning) {
|
2013-11-10 15:05:34 +00:00
|
|
|
if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK))
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
|
|
|
} else {
|
2014-03-03 04:09:18 +00:00
|
|
|
// Don't flush when weight count changes, unless morph is enabled.
|
|
|
|
if ((diff & ~GE_VTYPE_WEIGHTCOUNT_MASK) || (data & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
2013-11-10 12:18:52 +00:00
|
|
|
// Restore and flush
|
|
|
|
gstate.vertType ^= diff;
|
|
|
|
Flush();
|
|
|
|
gstate.vertType ^= diff;
|
2013-11-10 15:05:34 +00:00
|
|
|
if (diff & (GE_VTYPE_TC_MASK | GE_VTYPE_THROUGH_MASK))
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
2013-11-10 12:18:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_REGION1:
|
|
|
|
case GE_CMD_REGION2:
|
2014-01-20 01:25:42 +00:00
|
|
|
if (diff) {
|
2013-07-15 13:49:43 +00:00
|
|
|
gstate_c.framebufChanged = true;
|
2014-01-20 01:25:42 +00:00
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
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:
|
2013-09-23 15:08:06 +00:00
|
|
|
if (diff)
|
|
|
|
gstate_c.textureChanged = true;
|
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:
|
2013-02-14 23:30:02 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_FOGCOLOR);
|
2013-01-14 19:43:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_FOG1:
|
2013-02-14 23:30:02 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_FOGCOEF);
|
2013-01-14 19:43:18 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_FOG2:
|
2013-02-14 23:30:02 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_FOGCOEF);
|
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:
|
2013-07-27 20:14:34 +00:00
|
|
|
if (diff) {
|
2013-07-27 22:18:41 +00:00
|
|
|
gstate_c.uv.uScale = getFloat24(data);
|
2013-10-01 16:33:32 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
2013-07-27 20:14:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXSCALEV:
|
2013-07-27 20:14:34 +00:00
|
|
|
if (diff) {
|
2013-07-27 22:18:41 +00:00
|
|
|
gstate_c.uv.vScale = getFloat24(data);
|
2013-10-01 16:33:32 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
2013-07-27 20:14:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXOFFSETU:
|
2013-07-27 20:14:34 +00:00
|
|
|
if (diff) {
|
2013-07-27 22:18:41 +00:00
|
|
|
gstate_c.uv.uOff = getFloat24(data);
|
2013-10-01 16:33:32 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
2013-07-27 20:14:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXOFFSETV:
|
2013-07-27 20:14:34 +00:00
|
|
|
if (diff) {
|
2013-07-27 22:18:41 +00:00
|
|
|
gstate_c.uv.vOff = getFloat24(data);
|
2013-10-01 16:33:32 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
2013-07-27 20:14:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_SCISSOR1:
|
|
|
|
case GE_CMD_SCISSOR2:
|
2014-01-20 01:25:42 +00:00
|
|
|
if (diff) {
|
2013-09-19 17:48:43 +00:00
|
|
|
gstate_c.framebufChanged = true;
|
2014-01-20 01:25:42 +00:00
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
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-01-20 01:25:42 +00:00
|
|
|
if (diff) {
|
2013-04-21 22:08:47 +00:00
|
|
|
gstate_c.framebufChanged = true;
|
2014-01-20 01:25:42 +00:00
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXADDR0:
|
|
|
|
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:
|
2013-10-08 20:59:40 +00:00
|
|
|
if (diff) {
|
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TEXBUFWIDTH0:
|
|
|
|
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:
|
2013-10-08 20:59:40 +00:00
|
|
|
if (diff) {
|
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-02-23 18:05:06 +00:00
|
|
|
case GE_CMD_CLUTFORMAT:
|
2013-10-08 20:59:40 +00:00
|
|
|
if (diff) {
|
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
2012-11-18 12:04:49 +00:00
|
|
|
// This could be used to "dirty" textures with clut.
|
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:
|
|
|
|
gstate_c.textureChanged = true;
|
2013-05-12 17:57:41 +00:00
|
|
|
textureCache_.LoadClut();
|
2013-05-11 22:45:17 +00:00
|
|
|
// This could be used to "dirty" textures with clut.
|
|
|
|
break;
|
|
|
|
|
2012-12-19 14:14:41 +00:00
|
|
|
case GE_CMD_TEXMAPMODE:
|
2013-07-09 23:22:15 +00:00
|
|
|
if (diff) {
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2012-11-22 19:14:24 +00:00
|
|
|
case GE_CMD_TRANSFERSTART: // Orphis calls this TRXKICK
|
2012-11-01 15:19:01 +00:00
|
|
|
{
|
2012-11-02 11:33:16 +00:00
|
|
|
// TODO: Here we should check if the transfer overlaps a framebuffer or any textures,
|
2012-11-22 19:57:41 +00:00
|
|
|
// and take appropriate action. This is a block transfer between RAM and VRAM, or vice versa.
|
2013-03-03 12:00:21 +00:00
|
|
|
// Can we skip this on SkipDraw?
|
2012-11-22 19:57:41 +00:00
|
|
|
DoBlockTransfer();
|
2013-08-18 23:07:42 +00:00
|
|
|
|
2013-09-23 15:08:06 +00:00
|
|
|
// Fixes Gran Turismo's funky text issue, since it overwrites the current texture.
|
2013-08-18 23:07:42 +00:00
|
|
|
gstate_c.textureChanged = true;
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case GE_CMD_TEXSIZE0:
|
2013-11-11 13:12:43 +00:00
|
|
|
// Render to texture may have overridden the width/height.
|
|
|
|
// Don't reset it unless the size is different / the texture has changed.
|
|
|
|
if (diff || gstate_c.textureChanged) {
|
|
|
|
gstate_c.curTextureWidth = gstate.getTextureWidth(0);
|
|
|
|
gstate_c.curTextureHeight = gstate.getTextureHeight(0);
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_UVSCALEOFFSET);
|
|
|
|
// We will need to reset the texture now.
|
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
//fall thru - ignoring the mipmap sizes for now
|
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:
|
2013-11-30 14:54:20 +00:00
|
|
|
if (diff) {
|
2013-11-11 13:12:43 +00:00
|
|
|
gstate_c.textureChanged = true;
|
2013-11-30 14:54:20 +00:00
|
|
|
}
|
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:
|
2013-02-12 20:00:51 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_AMBIENT);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MATERIALDIFFUSE:
|
2012-12-20 17:31:21 +00:00
|
|
|
if (diff)
|
2012-12-25 12:47:59 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_MATDIFFUSE);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_MATERIALEMISSIVE:
|
2012-12-20 17:31:21 +00:00
|
|
|
if (diff)
|
2012-12-25 12:47:59 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_MATEMISSIVE);
|
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:
|
2012-12-20 13:10:42 +00:00
|
|
|
if (diff)
|
2012-12-25 12:47:59 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_MATAMBIENTALPHA);
|
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:
|
2012-12-20 17:31:21 +00:00
|
|
|
if (diff)
|
2012-12-25 12:47:59 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_MATSPECULAR);
|
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_LX1:case GE_CMD_LY1:case GE_CMD_LZ1:
|
|
|
|
case GE_CMD_LX2:case GE_CMD_LY2:case GE_CMD_LZ2:
|
|
|
|
case GE_CMD_LX3:case GE_CMD_LY3:case GE_CMD_LZ3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2012-11-01 15:19:01 +00:00
|
|
|
int n = cmd - GE_CMD_LX0;
|
|
|
|
int l = n / 3;
|
|
|
|
int c = n % 3;
|
2012-12-28 18:33:26 +00:00
|
|
|
gstate_c.lightpos[l][c] = getFloat24(data);
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LDX0:case GE_CMD_LDY0:case GE_CMD_LDZ0:
|
|
|
|
case GE_CMD_LDX1:case GE_CMD_LDY1:case GE_CMD_LDZ1:
|
|
|
|
case GE_CMD_LDX2:case GE_CMD_LDY2:case GE_CMD_LDZ2:
|
|
|
|
case GE_CMD_LDX3:case GE_CMD_LDY3:case GE_CMD_LDZ3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2012-11-01 15:19:01 +00:00
|
|
|
int n = cmd - GE_CMD_LDX0;
|
|
|
|
int l = n / 3;
|
|
|
|
int c = n % 3;
|
2012-12-28 18:33:26 +00:00
|
|
|
gstate_c.lightdir[l][c] = getFloat24(data);
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LKA0:case GE_CMD_LKB0:case GE_CMD_LKC0:
|
|
|
|
case GE_CMD_LKA1:case GE_CMD_LKB1:case GE_CMD_LKC1:
|
|
|
|
case GE_CMD_LKA2:case GE_CMD_LKB2:case GE_CMD_LKC2:
|
|
|
|
case GE_CMD_LKA3:case GE_CMD_LKB3:case GE_CMD_LKC3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2012-11-01 15:19:01 +00:00
|
|
|
int n = cmd - GE_CMD_LKA0;
|
|
|
|
int l = n / 3;
|
|
|
|
int c = n % 3;
|
2012-12-28 18:33:26 +00:00
|
|
|
gstate_c.lightatt[l][c] = getFloat24(data);
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-04-09 16:25:22 +00:00
|
|
|
case GE_CMD_LKS0:
|
|
|
|
case GE_CMD_LKS1:
|
|
|
|
case GE_CMD_LKS2:
|
|
|
|
case GE_CMD_LKS3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2013-04-09 16:25:22 +00:00
|
|
|
int l = cmd - GE_CMD_LKS0;
|
|
|
|
gstate_c.lightspotCoef[l] = getFloat24(data);
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2013-04-09 16:25:22 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_LKO0:
|
|
|
|
case GE_CMD_LKO1:
|
|
|
|
case GE_CMD_LKO2:
|
|
|
|
case GE_CMD_LKO3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2013-04-09 16:25:22 +00:00
|
|
|
int l = cmd - GE_CMD_LKO0;
|
|
|
|
gstate_c.lightangle[l] = getFloat24(data);
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2013-04-09 16:25:22 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
case GE_CMD_LAC0:case GE_CMD_LAC1:case GE_CMD_LAC2:case GE_CMD_LAC3:
|
|
|
|
case GE_CMD_LDC0:case GE_CMD_LDC1:case GE_CMD_LDC2:case GE_CMD_LDC3:
|
|
|
|
case GE_CMD_LSC0:case GE_CMD_LSC1:case GE_CMD_LSC2:case GE_CMD_LSC3:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff) {
|
2013-11-10 15:05:57 +00:00
|
|
|
float r = (float)(data & 0xff) * (1.0f / 255.0f);
|
|
|
|
float g = (float)((data >> 8) & 0xff) * (1.0f / 255.0f);
|
|
|
|
float b = (float)(data >> 16) * (1.0f / 255.0f);
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
int l = (cmd - GE_CMD_LAC0) / 3;
|
|
|
|
int t = (cmd - GE_CMD_LAC0) % 3;
|
2012-12-21 15:49:42 +00:00
|
|
|
gstate_c.lightColor[t][l][0] = r;
|
|
|
|
gstate_c.lightColor[t][l][1] = g;
|
|
|
|
gstate_c.lightColor[t][l][2] = b;
|
2013-11-10 10:18:58 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_LIGHT0 << l);
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VIEWPORTX1:
|
|
|
|
case GE_CMD_VIEWPORTY1:
|
|
|
|
case GE_CMD_VIEWPORTX2:
|
|
|
|
case GE_CMD_VIEWPORTY2:
|
2012-11-24 23:15:21 +00:00
|
|
|
case GE_CMD_VIEWPORTZ1:
|
|
|
|
case GE_CMD_VIEWPORTZ2:
|
2014-01-20 01:25:42 +00:00
|
|
|
if (diff) {
|
2013-08-23 11:35:23 +00:00
|
|
|
gstate_c.framebufChanged = true;
|
2014-01-20 01:25:42 +00:00
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
}
|
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:
|
|
|
|
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:
|
|
|
|
case GE_CMD_COLORTESTMASK:
|
2013-06-24 17:25:22 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_COLORMASK);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2013-08-23 11:35:23 +00:00
|
|
|
case GE_CMD_ALPHATEST:
|
2014-02-08 18:29:22 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-05-25 05:10:12 +00:00
|
|
|
if (((data >> 16) & 0xFF) != 0xFF && (data & 7) > 1)
|
2013-09-07 20:31:14 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(alphatestmask, G3D, "Unsupported alphatest mask: %02x", (data >> 16) & 0xFF);
|
2013-05-11 05:51:23 +00:00
|
|
|
#endif
|
2014-03-04 08:10:27 +00:00
|
|
|
// Intentional fallthrough - we still need to dirty DIRTY_ALPHACOLORREF for GE_CMD_ALPHATEST.
|
2013-08-23 11:35:23 +00:00
|
|
|
|
2013-05-11 05:51:23 +00:00
|
|
|
case GE_CMD_COLORREF:
|
2013-06-24 17:25:22 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_ALPHACOLORREF);
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
2012-12-01 22:38:18 +00:00
|
|
|
case GE_CMD_TEXENVCOLOR:
|
2013-06-24 17:25:22 +00:00
|
|
|
if (diff)
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_TEXENV);
|
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_TEXMODE:
|
|
|
|
case GE_CMD_TEXFORMAT:
|
2013-09-23 12:49:24 +00:00
|
|
|
case GE_CMD_TEXFILTER:
|
2012-11-28 12:45:22 +00:00
|
|
|
case GE_CMD_TEXWRAP:
|
2013-09-23 15:08:06 +00:00
|
|
|
if (diff)
|
|
|
|
gstate_c.textureChanged = true;
|
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:
|
2013-11-10 10:18:58 +00:00
|
|
|
if (diff)
|
|
|
|
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-03-04 09:09:04 +00:00
|
|
|
{
|
|
|
|
// This is almost always followed by GE_CMD_WORLDMATRIXDATA.
|
|
|
|
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
|
|
|
|
u32 *dst = (u32 *)(gstate.worldMatrix + (data & 0xF));
|
|
|
|
const int end = 12 - (data & 0xF);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((src[i] >> 24) == GE_CMD_WORLDMATRIXDATA) {
|
|
|
|
const u32 newVal = src[i] << 8;
|
|
|
|
if (dst[i] != newVal) {
|
|
|
|
Flush();
|
|
|
|
dst[i] = newVal;
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_WORLDMATRIX);
|
|
|
|
}
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int count = i;
|
|
|
|
gstate.worldmtxnum = (GE_CMD_WORLDMATRIXNUMBER << 24) | ((data + count) & 0xF);
|
|
|
|
|
|
|
|
// Skip over the loaded data, it's done now.
|
|
|
|
UpdatePC(currentList->pc, currentList->pc + count * 4);
|
|
|
|
currentList->pc += count * 4;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_WORLDMATRIXDATA:
|
2012-11-26 17:04:34 +00:00
|
|
|
{
|
2014-03-04 09:09:04 +00:00
|
|
|
// Note: it's uncommon to get here now, see above.
|
2012-11-26 17:04:34 +00:00
|
|
|
int num = gstate.worldmtxnum & 0xF;
|
2013-11-10 15:05:57 +00:00
|
|
|
u32 newVal = data << 8;
|
|
|
|
if (num < 12 && newVal != ((const u32 *)gstate.worldMatrix)[num]) {
|
2013-01-20 12:15:46 +00:00
|
|
|
Flush();
|
2013-11-10 15:05:57 +00:00
|
|
|
((u32 *)gstate.worldMatrix)[num] = newVal;
|
2013-01-20 12:15:46 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_WORLDMATRIX);
|
|
|
|
}
|
|
|
|
num++;
|
2013-08-10 23:25:14 +00:00
|
|
|
gstate.worldmtxnum = (GE_CMD_WORLDMATRIXNUMBER << 24) | (num & 0xF);
|
2012-11-26 17:04:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VIEWMATRIXNUMBER:
|
2014-03-04 08:37:28 +00:00
|
|
|
{
|
|
|
|
// This is almost always followed by GE_CMD_VIEWMATRIXDATA.
|
|
|
|
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
|
|
|
|
u32 *dst = (u32 *)(gstate.viewMatrix + (data & 0xF));
|
|
|
|
const int end = 12 - (data & 0xF);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((src[i] >> 24) == GE_CMD_VIEWMATRIXDATA) {
|
|
|
|
const u32 newVal = src[i] << 8;
|
|
|
|
if (dst[i] != newVal) {
|
|
|
|
Flush();
|
|
|
|
dst[i] = newVal;
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_VIEWMATRIX);
|
|
|
|
}
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int count = i;
|
|
|
|
gstate.viewmtxnum = (GE_CMD_VIEWMATRIXNUMBER << 24) | ((data + count) & 0xF);
|
|
|
|
|
|
|
|
// Skip over the loaded data, it's done now.
|
|
|
|
UpdatePC(currentList->pc, currentList->pc + count * 4);
|
|
|
|
currentList->pc += count * 4;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_VIEWMATRIXDATA:
|
2012-11-26 17:04:34 +00:00
|
|
|
{
|
2014-03-04 08:37:28 +00:00
|
|
|
// Note: it's uncommon to get here now, see above.
|
2012-11-26 17:04:34 +00:00
|
|
|
int num = gstate.viewmtxnum & 0xF;
|
2013-11-10 15:05:57 +00:00
|
|
|
u32 newVal = data << 8;
|
|
|
|
if (num < 12 && newVal != ((const u32 *)gstate.viewMatrix)[num]) {
|
2013-01-20 12:15:46 +00:00
|
|
|
Flush();
|
2013-11-10 15:05:57 +00:00
|
|
|
((u32 *)gstate.viewMatrix)[num] = newVal;
|
2013-01-20 12:15:46 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_VIEWMATRIX);
|
|
|
|
}
|
|
|
|
num++;
|
2013-08-10 23:25:14 +00:00
|
|
|
gstate.viewmtxnum = (GE_CMD_VIEWMATRIXNUMBER << 24) | (num & 0xF);
|
2012-11-26 17:04:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PROJMATRIXNUMBER:
|
2014-03-04 08:37:28 +00:00
|
|
|
{
|
|
|
|
// This is almost always followed by GE_CMD_PROJMATRIXDATA.
|
|
|
|
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
|
|
|
|
u32 *dst = (u32 *)(gstate.projMatrix + (data & 0xF));
|
|
|
|
const int end = 16 - (data & 0xF);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((src[i] >> 24) == GE_CMD_PROJMATRIXDATA) {
|
|
|
|
const u32 newVal = src[i] << 8;
|
|
|
|
if (dst[i] != newVal) {
|
|
|
|
Flush();
|
|
|
|
dst[i] = newVal;
|
2014-03-04 15:37:32 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_PROJMATRIX);
|
2014-03-04 08:37:28 +00:00
|
|
|
}
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int count = i;
|
|
|
|
gstate.projmtxnum = (GE_CMD_PROJMATRIXNUMBER << 24) | ((data + count) & 0xF);
|
|
|
|
|
|
|
|
// Skip over the loaded data, it's done now.
|
|
|
|
UpdatePC(currentList->pc, currentList->pc + count * 4);
|
|
|
|
currentList->pc += count * 4;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_PROJMATRIXDATA:
|
2012-11-26 17:04:34 +00:00
|
|
|
{
|
2014-03-04 08:37:28 +00:00
|
|
|
// Note: it's uncommon to get here now, see above.
|
2012-12-01 22:38:18 +00:00
|
|
|
int num = gstate.projmtxnum & 0xF;
|
2013-11-10 15:05:57 +00:00
|
|
|
u32 newVal = data << 8;
|
|
|
|
if (newVal != ((const u32 *)gstate.projMatrix)[num]) {
|
2013-01-20 12:15:46 +00:00
|
|
|
Flush();
|
2013-11-10 15:05:57 +00:00
|
|
|
((u32 *)gstate.projMatrix)[num] = newVal;
|
2013-10-30 13:44:31 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_PROJMATRIX);
|
2013-01-20 12:15:46 +00:00
|
|
|
}
|
|
|
|
num++;
|
2013-08-10 23:25:14 +00:00
|
|
|
gstate.projmtxnum = (GE_CMD_PROJMATRIXNUMBER << 24) | (num & 0xF);
|
2012-11-26 17:04:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TGENMATRIXNUMBER:
|
2014-03-04 08:21:20 +00:00
|
|
|
{
|
|
|
|
// This is almost always followed by GE_CMD_TGENMATRIXDATA.
|
|
|
|
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
|
|
|
|
u32 *dst = (u32 *)(gstate.tgenMatrix + (data & 0xF));
|
|
|
|
const int end = 12 - (data & 0xF);
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
while ((src[i] >> 24) == GE_CMD_TGENMATRIXDATA) {
|
2014-03-04 08:37:28 +00:00
|
|
|
const u32 newVal = src[i] << 8;
|
2014-03-04 08:21:20 +00:00
|
|
|
if (dst[i] != newVal) {
|
|
|
|
Flush();
|
|
|
|
dst[i] = newVal;
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_TEXMATRIX);
|
|
|
|
}
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int count = i;
|
|
|
|
gstate.texmtxnum = (GE_CMD_TGENMATRIXNUMBER << 24) | ((data + count) & 0xF);
|
|
|
|
|
|
|
|
// Skip over the loaded data, it's done now.
|
|
|
|
UpdatePC(currentList->pc, currentList->pc + count * 4);
|
|
|
|
currentList->pc += count * 4;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_TGENMATRIXDATA:
|
2012-11-26 17:04:34 +00:00
|
|
|
{
|
2014-03-04 08:21:20 +00:00
|
|
|
// Note: it's uncommon to get here now, see above.
|
2012-11-26 17:04:34 +00:00
|
|
|
int num = gstate.texmtxnum & 0xF;
|
2013-11-10 15:05:57 +00:00
|
|
|
u32 newVal = data << 8;
|
|
|
|
if (num < 12 && newVal != ((const u32 *)gstate.tgenMatrix)[num]) {
|
2013-01-20 12:15:46 +00:00
|
|
|
Flush();
|
2013-11-10 15:05:57 +00:00
|
|
|
((u32 *)gstate.tgenMatrix)[num] = newVal;
|
2013-01-20 12:15:46 +00:00
|
|
|
shaderManager_->DirtyUniform(DIRTY_TEXMATRIX);
|
|
|
|
}
|
|
|
|
num++;
|
2013-08-10 23:25:14 +00:00
|
|
|
gstate.texmtxnum = (GE_CMD_TGENMATRIXNUMBER << 24) | (num & 0xF);
|
2012-11-26 17:04:34 +00:00
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BONEMATRIXNUMBER:
|
2014-03-04 08:10:27 +00:00
|
|
|
{
|
|
|
|
// This is almost always followed by GE_CMD_BONEMATRIXDATA.
|
|
|
|
const u32_le *src = (const u32_le *)Memory::GetPointer(currentList->pc + 4);
|
|
|
|
u32 *dst = (u32 *)(gstate.boneMatrix + (data & 0x7F));
|
|
|
|
const int end = 12 * 8 - (data & 0x7F);
|
|
|
|
int i = 0;
|
|
|
|
|
2014-03-04 08:14:02 +00:00
|
|
|
// If we can't use software skinning, we have to flush and dirty.
|
2014-03-04 08:10:27 +00:00
|
|
|
if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
2014-03-04 08:14:02 +00:00
|
|
|
while ((src[i] >> 24) == GE_CMD_BONEMATRIXDATA) {
|
2014-03-04 08:37:28 +00:00
|
|
|
const u32 newVal = src[i] << 8;
|
2014-03-04 08:14:02 +00:00
|
|
|
if (dst[i] != newVal) {
|
|
|
|
Flush();
|
|
|
|
dst[i] = newVal;
|
|
|
|
}
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const int numPlusCount = (data & 0x7F) + i;
|
2014-03-04 08:10:27 +00:00
|
|
|
for (int num = data & 0x7F; num < numPlusCount; num += 12) {
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12));
|
|
|
|
}
|
2014-03-04 08:14:02 +00:00
|
|
|
} else {
|
|
|
|
while ((src[i] >> 24) == GE_CMD_BONEMATRIXDATA) {
|
|
|
|
dst[i] = src[i] << 8;
|
|
|
|
if (++i > end) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-03-04 08:10:27 +00:00
|
|
|
}
|
|
|
|
|
2014-03-04 08:14:02 +00:00
|
|
|
const int count = i;
|
2014-03-04 08:10:27 +00:00
|
|
|
gstate.boneMatrixNumber = (GE_CMD_BONEMATRIXNUMBER << 24) | ((data + count) & 0x7F);
|
|
|
|
|
|
|
|
// Skip over the loaded data, it's done now.
|
|
|
|
UpdatePC(currentList->pc, currentList->pc + count * 4);
|
|
|
|
currentList->pc += count * 4;
|
|
|
|
}
|
2012-11-01 15:19:01 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case GE_CMD_BONEMATRIXDATA:
|
2012-11-26 17:04:34 +00:00
|
|
|
{
|
2014-03-04 08:10:27 +00:00
|
|
|
// Note: it's uncommon to get here now, see above.
|
2012-11-26 17:04:34 +00:00
|
|
|
int num = gstate.boneMatrixNumber & 0x7F;
|
2013-11-10 15:05:34 +00:00
|
|
|
u32 newVal = data << 8;
|
|
|
|
if (num < 96 && newVal != ((const u32 *)gstate.boneMatrix)[num]) {
|
2013-11-10 12:18:52 +00:00
|
|
|
// Bone matrices should NOT flush when software skinning is enabled!
|
2014-03-03 02:19:55 +00:00
|
|
|
if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
2013-11-10 12:18:52 +00:00
|
|
|
Flush();
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12));
|
|
|
|
}
|
2013-11-10 15:05:34 +00:00
|
|
|
((u32 *)gstate.boneMatrix)[num] = newVal;
|
2012-11-26 19:38:26 +00:00
|
|
|
}
|
2013-01-20 12:15:46 +00:00
|
|
|
num++;
|
2013-08-10 23:25:14 +00:00
|
|
|
gstate.boneMatrixNumber = (GE_CMD_BONEMATRIXNUMBER << 24) | (num & 0x7F);
|
2012-11-26 17:04:34 +00:00
|
|
|
}
|
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-02-08 18:29:22 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-06-21 07:59:29 +00:00
|
|
|
if (data == 1)
|
|
|
|
WARN_LOG_REPORT_ONCE(texLevel1, G3D, "Unsupported texture level bias settings: %06x", data)
|
|
|
|
else if (data != 0)
|
2013-05-12 19:00:21 +00:00
|
|
|
WARN_LOG_REPORT_ONCE(texLevel2, G3D, "Unsupported texture level bias settings: %06x", data);
|
2014-02-08 18:29:22 +00:00
|
|
|
#endif
|
2013-09-23 15:08:06 +00:00
|
|
|
if (diff)
|
|
|
|
gstate_c.textureChanged = true;
|
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:
|
2013-12-26 03:18:16 +00:00
|
|
|
// Handled in StateMapping.
|
2013-12-02 23:09:48 +00:00
|
|
|
if (diff) {
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_STENCILREPLACEVALUE);
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
|
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_F0:
|
|
|
|
case GE_CMD_UNKNOWN_F1:
|
|
|
|
case GE_CMD_UNKNOWN_F2:
|
|
|
|
case GE_CMD_UNKNOWN_F3:
|
|
|
|
case GE_CMD_UNKNOWN_F4:
|
|
|
|
case GE_CMD_UNKNOWN_F5:
|
|
|
|
case GE_CMD_UNKNOWN_F6:
|
|
|
|
case GE_CMD_UNKNOWN_F7:
|
|
|
|
case GE_CMD_UNKNOWN_F8:
|
|
|
|
case GE_CMD_UNKNOWN_F9:
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-03 02:12:40 +00:00
|
|
|
void GLES_GPU::FastLoadBoneMatrix(u32 target) {
|
2014-03-03 02:19:55 +00:00
|
|
|
if (!g_Config.bSoftwareSkinning || (gstate.vertType & GE_VTYPE_MORPHCOUNT_MASK) != 0) {
|
2014-03-03 02:12:40 +00:00
|
|
|
Flush();
|
|
|
|
const int num = gstate.boneMatrixNumber & 0x7F;
|
|
|
|
shaderManager_->DirtyUniform(DIRTY_BONEMATRIX0 << (num / 12));
|
|
|
|
if ((num % 12) != 0) {
|
|
|
|
shaderManager_->DirtyUniform((DIRTY_BONEMATRIX0 << (num / 12)) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gstate.FastLoadBoneMatrix(target);
|
|
|
|
}
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
void GLES_GPU::UpdateStats() {
|
2012-12-25 12:47:59 +00:00
|
|
|
gpuStats.numVertexShaders = shaderManager_->NumVertexShaders();
|
|
|
|
gpuStats.numFragmentShaders = shaderManager_->NumFragmentShaders();
|
|
|
|
gpuStats.numShaders = shaderManager_->NumPrograms();
|
2013-02-24 18:38:30 +00:00
|
|
|
gpuStats.numTextures = (int)textureCache_.NumLoadedTextures();
|
|
|
|
gpuStats.numFBOs = (int)framebufferManager_.NumVFBs();
|
2012-11-26 16:35:08 +00:00
|
|
|
}
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
void GLES_GPU::DoBlockTransfer() {
|
2012-12-21 15:49:42 +00:00
|
|
|
// TODO: This is used a lot to copy data around between render targets and textures,
|
|
|
|
// and also to quickly load textures from RAM to VRAM. So we should do checks like the following:
|
2012-12-21 22:10:57 +00:00
|
|
|
// * Does dstBasePtr point to an existing texture? If so maybe reload it immediately.
|
2012-12-21 15:49:42 +00:00
|
|
|
//
|
|
|
|
// * Does srcBasePtr point to a render target, and dstBasePtr to a texture? If so
|
|
|
|
// either copy between rt and texture or reassign the texture to point to the render target
|
|
|
|
//
|
|
|
|
// etc....
|
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
u32 srcBasePtr = gstate.getTransferSrcAddress();
|
|
|
|
u32 srcStride = gstate.getTransferSrcStride();
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
u32 dstBasePtr = gstate.getTransferDstAddress();
|
|
|
|
u32 dstStride = gstate.getTransferDstStride();
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
int srcX = gstate.getTransferSrcX();
|
|
|
|
int srcY = gstate.getTransferSrcY();
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
int dstX = gstate.getTransferDstX();
|
|
|
|
int dstY = gstate.getTransferDstY();
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
int width = gstate.getTransferWidth();
|
|
|
|
int height = gstate.getTransferHeight();
|
2012-12-26 23:18:45 +00:00
|
|
|
|
2013-08-24 17:41:45 +00:00
|
|
|
int bpp = gstate.getTransferBpp();
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-08-18 23:07:42 +00:00
|
|
|
DEBUG_LOG(G3D, "Block transfer: %08x/%x -> %08x/%x, %ix%ix%i (%i,%i)->(%i,%i)", srcBasePtr, srcStride, dstBasePtr, dstStride, width, height, bpp, srcX, srcY, dstX, dstY);
|
2013-12-04 10:34:54 +00:00
|
|
|
|
2013-09-04 08:38:39 +00:00
|
|
|
if (!Memory::IsValidAddress(srcBasePtr)) {
|
2013-09-04 08:58:52 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "BlockTransfer: Bad source transfer address %08x!", srcBasePtr);
|
2013-09-04 08:38:39 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-22 19:57:41 +00:00
|
|
|
|
2013-09-04 08:38:39 +00:00
|
|
|
if (!Memory::IsValidAddress(dstBasePtr)) {
|
2013-09-04 08:58:52 +00:00
|
|
|
ERROR_LOG_REPORT(G3D, "BlockTransfer: Bad destination transfer address %08x!", dstBasePtr);
|
2013-09-04 08:38:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-01-16 21:52:14 +00:00
|
|
|
// Check that the last address of both source and dest are valid addresses
|
|
|
|
|
|
|
|
u32 srcLastAddr = srcBasePtr + ((height - 1 + srcY) * srcStride + (srcX + width - 1)) * bpp;
|
|
|
|
u32 dstLastAddr = dstBasePtr + ((height - 1 + dstY) * dstStride + (dstX + width - 1)) * bpp;
|
|
|
|
|
|
|
|
if (!Memory::IsValidAddress(srcLastAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bottom-right corner of source of block transfer is at an invalid address: %08x", srcLastAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!Memory::IsValidAddress(dstLastAddr)) {
|
|
|
|
ERROR_LOG_REPORT(G3D, "Bottom-right corner of destination of block transfer is at an invalid address: %08x", srcLastAddr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-10-22 09:19:06 +00:00
|
|
|
// Do the copy! (Hm, if we detect a drawn video frame (see below) then we could maybe skip this?)
|
2013-12-04 10:34:54 +00:00
|
|
|
// Can use GetPointerUnchecked because we checked the addresses above. We could also avoid them
|
|
|
|
// entirely by walking a couple of pointers...
|
2014-01-16 14:01:38 +00:00
|
|
|
// GetPointerUnchecked crash in windows 64 bit of issue 2301
|
2012-11-22 19:57:41 +00:00
|
|
|
for (int y = 0; y < height; y++) {
|
2014-01-16 21:52:14 +00:00
|
|
|
u32 srcLineStartAddr = srcBasePtr + ((y + srcY) * srcStride + srcX) * bpp;
|
|
|
|
u32 dstLineStartAddr = dstBasePtr + ((y + dstY) * dstStride + dstX) * bpp;
|
|
|
|
|
|
|
|
const u8 *src = Memory::GetPointerUnchecked(srcLineStartAddr);
|
|
|
|
u8 *dst = Memory::GetPointerUnchecked(dstLineStartAddr);
|
2012-11-22 19:57:41 +00:00
|
|
|
memcpy(dst, src, width * bpp);
|
|
|
|
}
|
|
|
|
|
2012-12-28 18:33:26 +00:00
|
|
|
// TODO: Notify all overlapping FBOs that they need to reload.
|
2014-01-20 09:47:20 +00:00
|
|
|
framebufferManager_.NotifyBlockTransfer(dstBasePtr, srcBasePtr);
|
2012-12-21 22:10:57 +00:00
|
|
|
|
2013-07-15 15:54:44 +00:00
|
|
|
textureCache_.Invalidate(dstBasePtr + (dstY * dstStride + dstX) * bpp, height * dstStride * bpp, GPU_INVALIDATE_HINT);
|
2013-12-15 00:45:29 +00:00
|
|
|
if (Memory::IsRAMAddress(srcBasePtr) && Memory::IsVRAMAddress(dstBasePtr)) {
|
|
|
|
// TODO: This causes glitches in Tactics Ogre if we don't implement both ways (which will probably be slow...)
|
|
|
|
// The main thing this helps is videos, which will have a matching stride, and zero x/y.
|
|
|
|
if (dstStride == srcStride && dstY == 0 && dstX == 0 && srcX == 0 && srcY == 0) {
|
|
|
|
framebufferManager_.UpdateFromMemory(dstBasePtr, (dstY + height) * dstStride * bpp, true);
|
|
|
|
}
|
|
|
|
}
|
2013-06-05 21:03:42 +00:00
|
|
|
|
|
|
|
// A few games use this INSTEAD of actually drawing the video image to the screen, they just blast it to
|
|
|
|
// the backbuffer. Detect this and have the framebuffermanager draw the pixels.
|
|
|
|
|
2013-06-05 22:01:43 +00:00
|
|
|
u32 backBuffer = framebufferManager_.PrevDisplayFramebufAddr();
|
2013-06-06 08:30:05 +00:00
|
|
|
u32 displayBuffer = framebufferManager_.DisplayFramebufAddr();
|
2013-06-05 21:03:42 +00:00
|
|
|
|
2013-06-11 07:34:16 +00:00
|
|
|
if (((backBuffer != 0 && dstBasePtr == backBuffer) ||
|
|
|
|
(displayBuffer != 0 && dstBasePtr == displayBuffer)) &&
|
2013-06-06 08:30:05 +00:00
|
|
|
dstStride == 512 && height == 272) {
|
2013-12-04 10:34:54 +00:00
|
|
|
framebufferManager_.DrawPixels(Memory::GetPointerUnchecked(dstBasePtr), GE_FORMAT_8888, 512);
|
2013-06-05 21:03:42 +00:00
|
|
|
}
|
2013-12-14 22:54:05 +00:00
|
|
|
|
2014-02-08 18:29:22 +00:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-12-14 22:54:05 +00:00
|
|
|
CBreakPoints::ExecMemCheck(srcBasePtr + (srcY * srcStride + srcX) * bpp, false, height * srcStride * bpp, currentMIPS->pc);
|
|
|
|
CBreakPoints::ExecMemCheck(dstBasePtr + (srcY * dstStride + srcX) * bpp, true, height * dstStride * bpp, currentMIPS->pc);
|
|
|
|
#endif
|
2012-12-21 22:10:57 +00:00
|
|
|
}
|
|
|
|
|
2013-05-06 05:52:01 +00:00
|
|
|
void GLES_GPU::InvalidateCache(u32 addr, int size, GPUInvalidationType type) {
|
2013-08-08 06:59:32 +00:00
|
|
|
GPUEvent ev(GPU_EVENT_INVALIDATE_CACHE);
|
|
|
|
ev.invalidate_cache.addr = addr;
|
|
|
|
ev.invalidate_cache.size = size;
|
|
|
|
ev.invalidate_cache.type = type;
|
|
|
|
ScheduleEvent(ev);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::InvalidateCacheInternal(u32 addr, int size, GPUInvalidationType type) {
|
2012-12-21 22:10:57 +00:00
|
|
|
if (size > 0)
|
2013-05-06 05:52:01 +00:00
|
|
|
textureCache_.Invalidate(addr, size, type);
|
2012-12-21 22:10:57 +00:00
|
|
|
else
|
2013-05-06 05:52:01 +00:00
|
|
|
textureCache_.InvalidateAll(type);
|
2013-06-08 11:37:40 +00:00
|
|
|
|
|
|
|
if (type != GPU_INVALIDATE_ALL)
|
2013-10-26 07:36:37 +00:00
|
|
|
framebufferManager_.UpdateFromMemory(addr, size, type == GPU_INVALIDATE_SAFE);
|
2012-11-22 19:57:41 +00:00
|
|
|
}
|
2012-12-25 12:47:59 +00:00
|
|
|
|
2013-06-09 08:21:50 +00:00
|
|
|
void GLES_GPU::UpdateMemory(u32 dest, u32 src, int size) {
|
|
|
|
InvalidateCache(dest, size, GPU_INVALIDATE_HINT);
|
2013-09-21 16:52:30 +00:00
|
|
|
|
|
|
|
// Track stray copies of a framebuffer in RAM. MotoGP does this.
|
|
|
|
if (Memory::IsVRAMAddress(src) && Memory::IsRAMAddress(dest)) {
|
|
|
|
framebufferManager_.NotifyFramebufferCopy(src, dest, size);
|
|
|
|
}
|
2013-06-09 08:21:50 +00:00
|
|
|
}
|
|
|
|
|
2013-04-30 15:20:28 +00:00
|
|
|
void GLES_GPU::ClearCacheNextFrame() {
|
|
|
|
textureCache_.ClearNextFrame();
|
|
|
|
}
|
|
|
|
|
2013-01-26 23:15:39 +00:00
|
|
|
void GLES_GPU::Resized() {
|
2013-01-31 11:14:57 +00:00
|
|
|
framebufferManager_.Resized();
|
2013-10-22 12:34:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GLES_GPU::ClearShaderCache() {
|
2013-10-22 11:00:19 +00:00
|
|
|
shaderManager_->ClearCache(true);
|
2013-01-26 23:15:39 +00:00
|
|
|
}
|
|
|
|
|
2013-10-22 12:34:16 +00:00
|
|
|
std::vector<FramebufferInfo> GLES_GPU::GetFramebufferList() {
|
2013-02-17 00:06:06 +00:00
|
|
|
return framebufferManager_.GetFramebufferList();
|
|
|
|
}
|
|
|
|
|
2013-01-26 23:15:39 +00:00
|
|
|
void GLES_GPU::DoState(PointerWrap &p) {
|
|
|
|
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) {
|
2013-09-29 20:19:32 +00:00
|
|
|
textureCache_.Clear(true);
|
|
|
|
transformDraw_.ClearTrackedVertexArrays();
|
2013-01-26 23:15:39 +00:00
|
|
|
|
2013-09-29 20:19:32 +00:00
|
|
|
gstate_c.textureChanged = true;
|
|
|
|
framebufferManager_.DestroyAllFBOs();
|
|
|
|
}
|
2012-12-29 20:21:56 +00:00
|
|
|
}
|
2013-09-23 02:03:31 +00:00
|
|
|
|
2013-09-28 04:53:42 +00:00
|
|
|
bool GLES_GPU::GetCurrentFramebuffer(GPUDebugBuffer &buffer) {
|
2013-09-23 02:03:31 +00:00
|
|
|
return framebufferManager_.GetCurrentFramebuffer(buffer);
|
|
|
|
}
|
2013-09-28 04:53:42 +00:00
|
|
|
|
2013-09-28 09:14:27 +00:00
|
|
|
bool GLES_GPU::GetCurrentDepthbuffer(GPUDebugBuffer &buffer) {
|
|
|
|
return framebufferManager_.GetCurrentDepthbuffer(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool GLES_GPU::GetCurrentStencilbuffer(GPUDebugBuffer &buffer) {
|
|
|
|
return framebufferManager_.GetCurrentStencilbuffer(buffer);
|
|
|
|
}
|
|
|
|
|
2013-09-28 04:53:42 +00:00
|
|
|
bool GLES_GPU::GetCurrentTexture(GPUDebugBuffer &buffer) {
|
|
|
|
if (!gstate.isTextureMapEnabled()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef USING_GLES2
|
|
|
|
textureCache_.SetTexture(true);
|
|
|
|
int w = gstate.getTextureWidth(0);
|
|
|
|
int h = gstate.getTextureHeight(0);
|
|
|
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w);
|
|
|
|
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h);
|
|
|
|
|
2013-10-07 07:38:46 +00:00
|
|
|
buffer.Allocate(w, h, GE_FORMAT_8888, gstate_c.flipTexture);
|
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
|
|
|
|
|
|
|
bool GLES_GPU::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) {
|
|
|
|
return transformDraw_.GetCurrentSimpleVertices(count, vertices, indices);
|
|
|
|
}
|
2013-12-01 02:39:16 +00:00
|
|
|
|
|
|
|
bool GLES_GPU::DescribeCodePtr(const u8 *ptr, std::string &name) {
|
|
|
|
if (transformDraw_.IsCodePtrVertexDecoder(ptr)) {
|
|
|
|
name = "VertexDecoderJit";
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|