2012-11-01 16:19:01 +01: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 23:01:49 +01:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 16:19:01 +01: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-10-09 11:01:52 +02:00
|
|
|
// Ideas for speeding things up on mobile OpenGL ES implementations
|
|
|
|
//
|
|
|
|
// Use superbuffers! Yes I just invented that name.
|
|
|
|
//
|
|
|
|
// The idea is to avoid respecifying the vertex format between every draw call (multiple glVertexAttribPointer ...)
|
|
|
|
// by combining the contents of multiple draw calls into one buffer, as long as
|
|
|
|
// they have exactly the same output vertex format. (different input formats is fine! This way
|
|
|
|
// we can combine the data for multiple draws with different numbers of bones, as we consider numbones < 4 to be = 4)
|
|
|
|
// into one VBO.
|
|
|
|
//
|
|
|
|
// This will likely be a win because I believe that between every change of VBO + glVertexAttribPointer*N, the driver will
|
|
|
|
// perform a lot of validation, probably at draw call time, while all the validation can be skipped if the only thing
|
|
|
|
// that changes between two draw calls is simple state or texture or a matrix etc, not anything vertex related.
|
|
|
|
// Also the driver will have to manage hundreds instead of thousands of VBOs in games like GTA.
|
|
|
|
//
|
|
|
|
// * Every 10 frames or something, do the following:
|
|
|
|
// - Frame 1:
|
|
|
|
// + Mark all drawn buffers with in-frame sequence numbers (alternatively,
|
|
|
|
// just log them in an array)
|
|
|
|
// - Frame 2 (beginning?):
|
|
|
|
// + Take adjacent buffers that have the same output vertex format, and add them
|
|
|
|
// to a list of buffers to combine. Create said buffers with appropriate sizes
|
|
|
|
// and precompute the offsets that the draws should be written into.
|
|
|
|
// - Frame 2 (end):
|
|
|
|
// + Actually do the work of combining the buffers. This probably means re-decoding
|
|
|
|
// the vertices into a new one. Will also have to apply index offsets.
|
|
|
|
//
|
|
|
|
// Also need to change the drawing code so that we don't glBindBuffer and respecify glVAP if
|
|
|
|
// two subsequent drawcalls come from the same superbuffer.
|
|
|
|
//
|
|
|
|
// Or we ignore all of this including vertex caching and simply find a way to do highly optimized vertex streaming,
|
|
|
|
// like Dolphin is trying to. That will likely never be able to reach the same speed as perfectly optimized
|
|
|
|
// superbuffers though. For this we will have to JIT the vertex decoder but that's not too hard.
|
|
|
|
//
|
|
|
|
// Now, when do we delete superbuffers? Maybe when half the buffers within have been killed?
|
|
|
|
//
|
|
|
|
// Another idea for GTA which switches textures a lot while not changing much other state is to use ES 3 Array
|
|
|
|
// textures, if they are the same size (even if they aren't, might be okay to simply resize the textures to match
|
|
|
|
// if they're just a multiple of 2 away) or something. Then we'd have to add a W texture coordinate to choose the
|
|
|
|
// texture within the bound texture array to the vertex data when merging into superbuffers.
|
|
|
|
//
|
|
|
|
// There are even more things to try. For games that do matrix palette skinning by quickly switching bones and
|
|
|
|
// just drawing a few triangles per call (NBA, FF:CC, Tekken 6 etc) we could even collect matrices, upload them
|
|
|
|
// all at once, writing matrix indices into the vertices in addition to the weights, and then doing a single
|
|
|
|
// draw call with specially generated shader to draw the whole mesh. This code will be seriously complex though.
|
|
|
|
|
2013-10-09 16:08:36 +02:00
|
|
|
#include "base/logging.h"
|
2013-01-11 19:03:16 +01:00
|
|
|
#include "base/timeutil.h"
|
|
|
|
|
2013-01-29 00:48:13 +01:00
|
|
|
#include "Common/MemoryUtil.h"
|
2013-04-20 20:20:03 +02:00
|
|
|
#include "Core/MemMap.h"
|
|
|
|
#include "Core/Host.h"
|
|
|
|
#include "Core/System.h"
|
|
|
|
#include "Core/Reporting.h"
|
|
|
|
#include "Core/Config.h"
|
|
|
|
#include "Core/CoreTiming.h"
|
|
|
|
|
|
|
|
#include "native/gfx_es2/gl_state.h"
|
|
|
|
|
|
|
|
#include "GPU/Math3D.h"
|
|
|
|
#include "GPU/GPUState.h"
|
|
|
|
#include "GPU/ge_constants.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2014-03-25 00:21:04 -07:00
|
|
|
#include "GPU/Common/TextureDecoder.h"
|
2013-10-13 20:47:52 -07:00
|
|
|
#include "GPU/Common/SplineCommon.h"
|
2014-09-10 10:44:22 +02:00
|
|
|
#include "GPU/Common/VertexDecoderCommon.h"
|
2014-09-13 13:27:42 +02:00
|
|
|
#include "GPU/Common/SoftwareTransformCommon.h"
|
2014-08-24 15:26:38 -07:00
|
|
|
#include "GPU/GLES/FragmentTestCache.h"
|
2013-08-20 22:34:47 +02:00
|
|
|
#include "GPU/GLES/StateMapping.h"
|
|
|
|
#include "GPU/GLES/TextureCache.h"
|
|
|
|
#include "GPU/GLES/TransformPipeline.h"
|
|
|
|
#include "GPU/GLES/ShaderManager.h"
|
|
|
|
#include "GPU/GLES/GLES_GPU.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-11-13 14:56:34 +01:00
|
|
|
extern const GLuint glprim[8] = {
|
2012-11-01 16:19:01 +01:00
|
|
|
GL_POINTS,
|
|
|
|
GL_LINES,
|
|
|
|
GL_LINE_STRIP,
|
|
|
|
GL_TRIANGLES,
|
|
|
|
GL_TRIANGLE_STRIP,
|
|
|
|
GL_TRIANGLE_FAN,
|
2013-12-09 13:45:17 +01:00
|
|
|
GL_TRIANGLES,
|
|
|
|
// With OpenGL ES we have to expand sprites (rects) into triangles, tripling the data instead of doubling.
|
|
|
|
// Sigh. OpenGL ES, Y U NO SUPPORT GL_QUADS?
|
|
|
|
// We can use it on the desktop though, but we don't yet. There we could also use geometry shaders anyway.
|
2012-11-01 16:19:01 +01:00
|
|
|
};
|
|
|
|
|
2013-01-29 00:48:13 +01:00
|
|
|
enum {
|
2013-10-27 14:43:58 -07:00
|
|
|
VERTEX_BUFFER_MAX = 65536,
|
|
|
|
DECODED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 48,
|
|
|
|
DECODED_INDEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * 20,
|
|
|
|
TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex)
|
2013-01-29 00:48:13 +01:00
|
|
|
};
|
|
|
|
|
2014-12-14 01:49:48 +09:00
|
|
|
#define QUAD_INDICES_MAX 65536
|
2013-08-01 00:13:58 +02:00
|
|
|
|
|
|
|
#define VERTEXCACHE_DECIMATION_INTERVAL 17
|
2014-06-07 16:15:37 -07:00
|
|
|
#define VERTEXCACHE_NAME_CACHE_SIZE 64
|
2014-06-07 16:28:24 -07:00
|
|
|
#define VERTEXCACHE_NAME_CACHE_FULL_SIZE 80
|
2013-08-01 00:13:58 +02:00
|
|
|
|
2014-09-07 17:08:05 -07:00
|
|
|
enum { VAI_KILL_AGE = 120, VAI_UNRELIABLE_KILL_AGE = 240, VAI_UNRELIABLE_KILL_MAX = 4 };
|
2014-03-23 15:34:04 +01:00
|
|
|
|
|
|
|
|
2012-12-25 15:28:34 +01:00
|
|
|
TransformDrawEngine::TransformDrawEngine()
|
2014-03-23 15:34:04 +01:00
|
|
|
: decodedVerts_(0),
|
2013-08-25 19:51:06 +02:00
|
|
|
prevPrim_(GE_PRIM_INVALID),
|
2013-03-24 12:28:42 +01:00
|
|
|
dec_(0),
|
2013-01-19 19:22:15 +01:00
|
|
|
lastVType_(-1),
|
2013-02-18 08:34:51 -08:00
|
|
|
shaderManager_(0),
|
|
|
|
textureCache_(0),
|
|
|
|
framebufferManager_(0),
|
2013-07-28 00:18:41 +02:00
|
|
|
numDrawCalls(0),
|
2013-10-27 14:43:58 -07:00
|
|
|
vertexCountInDrawCalls(0),
|
2014-01-10 22:13:11 -08:00
|
|
|
decodeCounter_(0),
|
2014-09-15 07:08:55 -07:00
|
|
|
dcid_(0),
|
2014-05-12 21:47:55 -07:00
|
|
|
uvScale(0),
|
|
|
|
fboTexBound_(false) {
|
2013-08-01 00:13:58 +02:00
|
|
|
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
|
2014-09-10 10:16:42 +02:00
|
|
|
memset(&decOptions_, 0, sizeof(decOptions_));
|
|
|
|
decOptions_.expandAllUVtoFloat = false;
|
2013-01-29 00:48:13 +01:00
|
|
|
// Allocate nicely aligned memory. Maybe graphics drivers will
|
|
|
|
// appreciate it.
|
|
|
|
// All this is a LOT of memory, need to see if we can cut down somehow.
|
|
|
|
decoded = (u8 *)AllocateMemoryPages(DECODED_VERTEX_BUFFER_SIZE);
|
|
|
|
decIndex = (u16 *)AllocateMemoryPages(DECODED_INDEX_BUFFER_SIZE);
|
|
|
|
transformed = (TransformedVertex *)AllocateMemoryPages(TRANSFORMED_VERTEX_BUFFER_SIZE);
|
|
|
|
transformedExpanded = (TransformedVertex *)AllocateMemoryPages(3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
2013-09-24 11:14:04 +02:00
|
|
|
|
2014-09-18 00:40:25 +02:00
|
|
|
quadIndices_ = new u16[6 * QUAD_INDICES_MAX];
|
2013-09-24 11:14:04 +02:00
|
|
|
|
2013-07-28 00:18:41 +02:00
|
|
|
if (g_Config.bPrescaleUV) {
|
|
|
|
uvScale = new UVScale[MAX_DEFERRED_DRAW_CALLS];
|
|
|
|
}
|
2012-12-25 13:47:59 +01:00
|
|
|
indexGen.Setup(decIndex);
|
2013-11-03 15:27:12 +01:00
|
|
|
decJitCache_ = new VertexDecoderJitCache();
|
|
|
|
|
2013-01-10 12:51:18 +01:00
|
|
|
InitDeviceObjects();
|
|
|
|
register_gl_resource_holder(this);
|
2012-12-25 13:47:59 +01:00
|
|
|
}
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
TransformDrawEngine::~TransformDrawEngine() {
|
2013-01-10 12:51:18 +01:00
|
|
|
DestroyDeviceObjects();
|
2013-01-29 00:48:13 +01:00
|
|
|
FreeMemoryPages(decoded, DECODED_VERTEX_BUFFER_SIZE);
|
|
|
|
FreeMemoryPages(decIndex, DECODED_INDEX_BUFFER_SIZE);
|
|
|
|
FreeMemoryPages(transformed, TRANSFORMED_VERTEX_BUFFER_SIZE);
|
|
|
|
FreeMemoryPages(transformedExpanded, 3 * TRANSFORMED_VERTEX_BUFFER_SIZE);
|
2013-09-24 11:14:04 +02:00
|
|
|
delete [] quadIndices_;
|
|
|
|
|
2013-01-10 12:51:18 +01:00
|
|
|
unregister_gl_resource_holder(this);
|
2013-11-03 20:15:42 +01:00
|
|
|
delete decJitCache_;
|
2013-03-24 12:31:00 +01:00
|
|
|
for (auto iter = decoderMap_.begin(); iter != decoderMap_.end(); iter++) {
|
|
|
|
delete iter->second;
|
|
|
|
}
|
2013-07-28 00:18:41 +02:00
|
|
|
delete [] uvScale;
|
2013-01-10 12:51:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::InitDeviceObjects() {
|
2014-06-07 16:15:37 -07:00
|
|
|
if (bufferNameCache_.empty()) {
|
|
|
|
bufferNameCache_.resize(VERTEXCACHE_NAME_CACHE_SIZE);
|
|
|
|
glGenBuffers(VERTEXCACHE_NAME_CACHE_SIZE, &bufferNameCache_[0]);
|
2013-01-10 12:51:18 +01:00
|
|
|
} else {
|
|
|
|
ERROR_LOG(G3D, "Device objects already initialized!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::DestroyDeviceObjects() {
|
2014-06-07 16:15:37 -07:00
|
|
|
if (!bufferNameCache_.empty()) {
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.arrayBuffer.unbind();
|
|
|
|
glstate.elementArrayBuffer.unbind();
|
2014-06-07 16:15:37 -07:00
|
|
|
glDeleteBuffers((GLsizei)bufferNameCache_.size(), &bufferNameCache_[0]);
|
|
|
|
bufferNameCache_.clear();
|
|
|
|
}
|
2013-01-20 13:15:46 +01:00
|
|
|
ClearTrackedVertexArrays();
|
2013-01-10 12:51:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::GLLost() {
|
2013-10-09 16:08:36 +02:00
|
|
|
ILOG("TransformDrawEngine::GLLost()");
|
2013-01-10 12:51:18 +01:00
|
|
|
// The objects have already been deleted.
|
2014-06-07 16:15:37 -07:00
|
|
|
bufferNameCache_.clear();
|
2013-01-20 13:15:46 +01:00
|
|
|
ClearTrackedVertexArrays();
|
2013-01-10 12:51:18 +01:00
|
|
|
InitDeviceObjects();
|
2012-12-25 13:47:59 +01:00
|
|
|
}
|
|
|
|
|
2012-12-20 14:10:42 +01:00
|
|
|
struct GlTypeInfo {
|
2013-02-04 23:09:01 +01:00
|
|
|
u16 type;
|
|
|
|
u8 count;
|
|
|
|
u8 normalized;
|
2012-12-20 14:10:42 +01:00
|
|
|
};
|
2012-12-19 18:35:37 +01:00
|
|
|
|
2013-02-04 23:09:01 +01:00
|
|
|
static const GlTypeInfo GLComp[] = {
|
2012-12-20 14:10:42 +01:00
|
|
|
{0}, // DEC_NONE,
|
|
|
|
{GL_FLOAT, 1, GL_FALSE}, // DEC_FLOAT_1,
|
|
|
|
{GL_FLOAT, 2, GL_FALSE}, // DEC_FLOAT_2,
|
|
|
|
{GL_FLOAT, 3, GL_FALSE}, // DEC_FLOAT_3,
|
|
|
|
{GL_FLOAT, 4, GL_FALSE}, // DEC_FLOAT_4,
|
2013-01-22 21:57:47 +01:00
|
|
|
{GL_BYTE, 4, GL_TRUE}, // DEC_S8_3,
|
|
|
|
{GL_SHORT, 4, GL_TRUE},// DEC_S16_3,
|
2013-02-04 23:09:01 +01:00
|
|
|
{GL_UNSIGNED_BYTE, 1, GL_TRUE},// DEC_U8_1,
|
|
|
|
{GL_UNSIGNED_BYTE, 2, GL_TRUE},// DEC_U8_2,
|
2013-01-29 00:48:13 +01:00
|
|
|
{GL_UNSIGNED_BYTE, 3, GL_TRUE},// DEC_U8_3,
|
2013-02-04 23:09:01 +01:00
|
|
|
{GL_UNSIGNED_BYTE, 4, GL_TRUE},// DEC_U8_4,
|
2013-02-05 18:00:21 +01:00
|
|
|
{GL_UNSIGNED_SHORT, 1, GL_TRUE},// DEC_U16_1,
|
2013-02-05 01:37:00 +01:00
|
|
|
{GL_UNSIGNED_SHORT, 2, GL_TRUE},// DEC_U16_2,
|
2013-02-05 18:00:21 +01:00
|
|
|
{GL_UNSIGNED_SHORT, 3, GL_TRUE},// DEC_U16_3,
|
|
|
|
{GL_UNSIGNED_SHORT, 4, GL_TRUE},// DEC_U16_4,
|
2013-02-06 21:38:19 +01:00
|
|
|
{GL_UNSIGNED_BYTE, 2, GL_FALSE},// DEC_U8A_2,
|
2013-02-05 01:37:00 +01:00
|
|
|
{GL_UNSIGNED_SHORT, 2, GL_FALSE},// DEC_U16A_2,
|
2012-12-20 14:10:42 +01:00
|
|
|
};
|
2012-12-19 18:35:37 +01:00
|
|
|
|
2012-12-20 14:10:42 +01:00
|
|
|
static inline void VertexAttribSetup(int attrib, int fmt, int stride, u8 *ptr) {
|
|
|
|
if (attrib != -1 && fmt) {
|
|
|
|
const GlTypeInfo &type = GLComp[fmt];
|
|
|
|
glVertexAttribPointer(attrib, type.count, type.type, type.normalized, stride, ptr);
|
2012-12-05 10:45:28 +07:00
|
|
|
}
|
2012-12-20 14:10:42 +01:00
|
|
|
}
|
2012-12-05 10:45:28 +07:00
|
|
|
|
2012-12-20 14:10:42 +01:00
|
|
|
// TODO: Use VBO and get rid of the vertexData pointers - with that, we will supply only offsets
|
|
|
|
static void SetupDecFmtForDraw(LinkedShader *program, const DecVtxFormat &decFmt, u8 *vertexData) {
|
2013-10-08 17:18:59 +02:00
|
|
|
VertexAttribSetup(ATTR_W1, decFmt.w0fmt, decFmt.stride, vertexData + decFmt.w0off);
|
|
|
|
VertexAttribSetup(ATTR_W2, decFmt.w1fmt, decFmt.stride, vertexData + decFmt.w1off);
|
|
|
|
VertexAttribSetup(ATTR_TEXCOORD, decFmt.uvfmt, decFmt.stride, vertexData + decFmt.uvoff);
|
|
|
|
VertexAttribSetup(ATTR_COLOR0, decFmt.c0fmt, decFmt.stride, vertexData + decFmt.c0off);
|
|
|
|
VertexAttribSetup(ATTR_COLOR1, decFmt.c1fmt, decFmt.stride, vertexData + decFmt.c1off);
|
|
|
|
VertexAttribSetup(ATTR_NORMAL, decFmt.nrmfmt, decFmt.stride, vertexData + decFmt.nrmoff);
|
|
|
|
VertexAttribSetup(ATTR_POSITION, decFmt.posfmt, decFmt.stride, vertexData + decFmt.posoff);
|
2012-12-20 14:10:42 +01:00
|
|
|
}
|
|
|
|
|
2013-03-24 12:28:42 +01:00
|
|
|
VertexDecoder *TransformDrawEngine::GetVertexDecoder(u32 vtype) {
|
|
|
|
auto iter = decoderMap_.find(vtype);
|
|
|
|
if (iter != decoderMap_.end())
|
|
|
|
return iter->second;
|
2013-10-09 11:01:52 +02:00
|
|
|
VertexDecoder *dec = new VertexDecoder();
|
2014-09-10 10:16:42 +02:00
|
|
|
dec->SetVertexType(vtype, decOptions_, decJitCache_);
|
2013-03-24 12:28:42 +01:00
|
|
|
decoderMap_[vtype] = dec;
|
|
|
|
return dec;
|
|
|
|
}
|
|
|
|
|
2013-04-20 20:20:03 +02:00
|
|
|
void TransformDrawEngine::SetupVertexDecoder(u32 vertType) {
|
2014-04-05 01:25:04 -07:00
|
|
|
SetupVertexDecoderInternal(vertType);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void TransformDrawEngine::SetupVertexDecoderInternal(u32 vertType) {
|
2013-11-19 23:37:09 +01:00
|
|
|
// As the decoder depends on the UVGenMode when we use UV prescale, we simply mash it
|
|
|
|
// into the top of the verttype where there are unused bits.
|
2014-04-05 01:25:04 -07:00
|
|
|
const u32 vertTypeID = (vertType & 0xFFFFFF) | (gstate.getUVGenMode() << 24);
|
2013-11-19 23:37:09 +01:00
|
|
|
|
2013-04-20 20:20:03 +02:00
|
|
|
// If vtype has changed, setup the vertex decoder.
|
2013-11-19 23:37:09 +01:00
|
|
|
if (vertTypeID != lastVType_) {
|
|
|
|
dec_ = GetVertexDecoder(vertTypeID);
|
|
|
|
lastVType_ = vertTypeID;
|
2013-04-20 20:20:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-14 14:03:03 +01:00
|
|
|
void TransformDrawEngine::SubmitPrim(void *verts, void *inds, GEPrimitiveType prim, int vertexCount, u32 vertType, int *bytesRead) {
|
2013-10-27 14:43:58 -07:00
|
|
|
if (!indexGen.PrimCompatible(prevPrim_, prim) || numDrawCalls >= MAX_DEFERRED_DRAW_CALLS || vertexCountInDrawCalls + vertexCount > VERTEX_BUFFER_MAX)
|
2012-12-21 19:16:17 +01:00
|
|
|
Flush();
|
2013-10-09 11:01:52 +02:00
|
|
|
|
2014-10-19 20:25:04 +02:00
|
|
|
if ((vertexCount < 2 && prim > 0) || (vertexCount < 3 && prim > 2 && prim != GE_PRIM_RECTANGLES))
|
|
|
|
return;
|
|
|
|
|
2013-09-07 22:31:22 -07:00
|
|
|
// TODO: Is this the right thing to do?
|
2013-09-04 17:12:53 +08:00
|
|
|
if (prim == GE_PRIM_KEEP_PREVIOUS) {
|
2014-10-29 23:50:21 +01:00
|
|
|
prim = prevPrim_ != GE_PRIM_INVALID ? prevPrim_ : GE_PRIM_POINTS;
|
2014-10-19 20:25:04 +02:00
|
|
|
} else {
|
|
|
|
prevPrim_ = prim;
|
2013-09-04 17:12:53 +08:00
|
|
|
}
|
2013-10-09 11:01:52 +02:00
|
|
|
|
2014-04-05 01:25:04 -07:00
|
|
|
SetupVertexDecoderInternal(vertType);
|
2012-12-28 19:33:26 +01:00
|
|
|
|
2014-10-19 20:25:04 +02:00
|
|
|
*bytesRead = vertexCount * dec_->VertexSize();
|
2013-01-19 17:05:08 +01:00
|
|
|
|
2013-07-28 00:18:41 +02:00
|
|
|
DeferredDrawCall &dc = drawCalls[numDrawCalls];
|
2013-01-19 17:05:08 +01:00
|
|
|
dc.verts = verts;
|
|
|
|
dc.inds = inds;
|
|
|
|
dc.vertType = vertType;
|
2013-11-14 14:03:03 +01:00
|
|
|
dc.indexType = (vertType & GE_VTYPE_IDX_MASK) >> GE_VTYPE_IDX_SHIFT;
|
2013-01-19 17:05:08 +01:00
|
|
|
dc.prim = prim;
|
|
|
|
dc.vertexCount = vertexCount;
|
2014-03-23 01:51:51 +01:00
|
|
|
|
|
|
|
u32 dhash = dcid_;
|
2014-03-23 15:34:04 +01:00
|
|
|
dhash ^= (u32)(uintptr_t)verts;
|
2014-03-23 01:51:51 +01:00
|
|
|
dhash = __rotl(dhash, 13);
|
2014-03-23 15:34:04 +01:00
|
|
|
dhash ^= (u32)(uintptr_t)inds;
|
2014-03-23 01:51:51 +01:00
|
|
|
dhash = __rotl(dhash, 13);
|
2014-03-23 15:34:04 +01:00
|
|
|
dhash ^= (u32)vertType;
|
2014-03-23 01:51:51 +01:00
|
|
|
dhash = __rotl(dhash, 13);
|
2014-03-23 15:34:04 +01:00
|
|
|
dhash ^= (u32)vertexCount;
|
2014-03-23 01:51:51 +01:00
|
|
|
dhash = __rotl(dhash, 13);
|
2014-03-23 15:34:04 +01:00
|
|
|
dhash ^= (u32)prim;
|
2014-03-23 01:51:51 +01:00
|
|
|
dcid_ = dhash;
|
|
|
|
|
2013-01-19 17:05:08 +01:00
|
|
|
if (inds) {
|
|
|
|
GetIndexBounds(inds, vertexCount, vertType, &dc.indexLowerBound, &dc.indexUpperBound);
|
|
|
|
} else {
|
|
|
|
dc.indexLowerBound = 0;
|
|
|
|
dc.indexUpperBound = vertexCount - 1;
|
|
|
|
}
|
2013-07-28 00:18:41 +02:00
|
|
|
|
|
|
|
if (uvScale) {
|
|
|
|
uvScale[numDrawCalls] = gstate_c.uv;
|
|
|
|
}
|
2013-11-10 15:31:56 +01:00
|
|
|
|
2013-07-28 00:18:41 +02:00
|
|
|
numDrawCalls++;
|
2013-10-27 14:43:58 -07:00
|
|
|
vertexCountInDrawCalls += vertexCount;
|
2013-11-10 15:31:56 +01:00
|
|
|
|
|
|
|
if (g_Config.bSoftwareSkinning && (vertType & GE_VTYPE_WEIGHT_MASK)) {
|
|
|
|
DecodeVertsStep();
|
|
|
|
decodeCounter_++;
|
|
|
|
}
|
2014-06-22 20:37:50 +02:00
|
|
|
|
|
|
|
if (prim == GE_PRIM_RECTANGLES && (gstate.getTextureAddress(0) & 0x3FFFFFFF) == (gstate.getFrameBufAddress() & 0x3FFFFFFF)) {
|
2014-10-19 20:25:04 +02:00
|
|
|
// Rendertarget == texture?
|
2014-07-08 23:32:41 -07:00
|
|
|
if (!g_Config.bDisableSlowFramebufEffects) {
|
|
|
|
gstate_c.textureChanged |= TEXCHANGE_PARAMSONLY;
|
|
|
|
Flush();
|
|
|
|
}
|
2014-06-22 20:37:50 +02:00
|
|
|
}
|
2013-01-19 17:05:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::DecodeVerts() {
|
2014-06-29 15:45:55 -07:00
|
|
|
if (uvScale) {
|
|
|
|
const UVScale origUV = gstate_c.uv;
|
|
|
|
for (; decodeCounter_ < numDrawCalls; decodeCounter_++) {
|
2013-11-10 15:22:24 +01:00
|
|
|
gstate_c.uv = uvScale[decodeCounter_];
|
2014-06-29 15:45:55 -07:00
|
|
|
DecodeVertsStep();
|
|
|
|
}
|
|
|
|
gstate_c.uv = origUV;
|
|
|
|
} else {
|
|
|
|
for (; decodeCounter_ < numDrawCalls; decodeCounter_++) {
|
|
|
|
DecodeVertsStep();
|
|
|
|
}
|
2013-01-19 17:05:08 +01:00
|
|
|
}
|
2013-07-22 19:10:19 +02:00
|
|
|
// Sanity check
|
|
|
|
if (indexGen.Prim() < 0) {
|
2013-09-07 13:43:07 -07:00
|
|
|
ERROR_LOG_REPORT(G3D, "DecodeVerts: Failed to deduce prim: %i", indexGen.Prim());
|
2013-07-22 19:10:19 +02:00
|
|
|
// Force to points (0)
|
|
|
|
indexGen.AddPrim(GE_PRIM_POINTS, 0);
|
|
|
|
}
|
2013-01-19 17:05:08 +01:00
|
|
|
}
|
|
|
|
|
2013-11-10 15:22:24 +01:00
|
|
|
void TransformDrawEngine::DecodeVertsStep() {
|
|
|
|
const int i = decodeCounter_;
|
|
|
|
|
|
|
|
const DeferredDrawCall &dc = drawCalls[i];
|
|
|
|
|
2014-03-23 15:34:04 +01:00
|
|
|
indexGen.SetIndex(decodedVerts_);
|
2013-11-10 15:22:24 +01:00
|
|
|
int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound;
|
|
|
|
|
|
|
|
u32 indexType = dc.indexType;
|
2014-12-14 19:22:49 +01:00
|
|
|
if (indexType == (GE_VTYPE_IDX_NONE >> GE_VTYPE_IDX_SHIFT)) {
|
2013-11-10 15:22:24 +01:00
|
|
|
// Decode the verts and apply morphing. Simple.
|
2014-03-23 15:34:04 +01:00
|
|
|
dec_->DecodeVerts(decoded + decodedVerts_ * (int)dec_->GetDecVtxFmt().stride,
|
2013-11-10 15:22:24 +01:00
|
|
|
dc.verts, indexLowerBound, indexUpperBound);
|
2014-03-23 15:34:04 +01:00
|
|
|
decodedVerts_ += indexUpperBound - indexLowerBound + 1;
|
2013-11-10 15:22:24 +01:00
|
|
|
indexGen.AddPrim(dc.prim, dc.vertexCount);
|
|
|
|
} else {
|
|
|
|
// It's fairly common that games issue long sequences of PRIM calls, with differing
|
|
|
|
// inds pointer but the same base vertex pointer. We'd like to reuse vertices between
|
|
|
|
// these as much as possible, so we make sure here to combine as many as possible
|
|
|
|
// into one nice big drawcall, sharing data.
|
|
|
|
|
|
|
|
// 1. Look ahead to find the max index, only looking as "matching" drawcalls.
|
|
|
|
// Expand the lower and upper bounds as we go.
|
|
|
|
int lastMatch = i;
|
2014-04-05 12:32:10 -07:00
|
|
|
const int total = numDrawCalls;
|
|
|
|
if (uvScale) {
|
|
|
|
for (int j = i + 1; j < total; ++j) {
|
|
|
|
if (drawCalls[j].verts != dc.verts)
|
|
|
|
break;
|
|
|
|
if (memcmp(&uvScale[j], &uvScale[i], sizeof(uvScale[0])) != 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
indexLowerBound = std::min(indexLowerBound, (int)drawCalls[j].indexLowerBound);
|
|
|
|
indexUpperBound = std::max(indexUpperBound, (int)drawCalls[j].indexUpperBound);
|
|
|
|
lastMatch = j;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
for (int j = i + 1; j < total; ++j) {
|
|
|
|
if (drawCalls[j].verts != dc.verts)
|
|
|
|
break;
|
|
|
|
|
|
|
|
indexLowerBound = std::min(indexLowerBound, (int)drawCalls[j].indexLowerBound);
|
|
|
|
indexUpperBound = std::max(indexUpperBound, (int)drawCalls[j].indexUpperBound);
|
|
|
|
lastMatch = j;
|
|
|
|
}
|
2013-11-10 15:22:24 +01:00
|
|
|
}
|
2013-12-09 13:45:17 +01:00
|
|
|
|
2013-11-10 15:22:24 +01:00
|
|
|
// 2. Loop through the drawcalls, translating indices as we go.
|
2014-04-05 12:32:10 -07:00
|
|
|
switch (indexType) {
|
|
|
|
case GE_VTYPE_IDX_8BIT >> GE_VTYPE_IDX_SHIFT:
|
|
|
|
for (int j = i; j <= lastMatch; j++) {
|
2013-11-10 15:22:24 +01:00
|
|
|
indexGen.TranslatePrim(drawCalls[j].prim, drawCalls[j].vertexCount, (const u8 *)drawCalls[j].inds, indexLowerBound);
|
2014-04-05 12:32:10 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case GE_VTYPE_IDX_16BIT >> GE_VTYPE_IDX_SHIFT:
|
|
|
|
for (int j = i; j <= lastMatch; j++) {
|
2013-11-10 15:22:24 +01:00
|
|
|
indexGen.TranslatePrim(drawCalls[j].prim, drawCalls[j].vertexCount, (const u16 *)drawCalls[j].inds, indexLowerBound);
|
|
|
|
}
|
2014-04-05 12:32:10 -07:00
|
|
|
break;
|
2013-11-10 15:22:24 +01:00
|
|
|
}
|
|
|
|
|
2014-04-05 12:32:10 -07:00
|
|
|
const int vertexCount = indexUpperBound - indexLowerBound + 1;
|
2013-11-10 15:22:24 +01:00
|
|
|
// 3. Decode that range of vertex data.
|
2014-03-23 15:34:04 +01:00
|
|
|
dec_->DecodeVerts(decoded + decodedVerts_ * (int)dec_->GetDecVtxFmt().stride,
|
2013-11-10 15:22:24 +01:00
|
|
|
dc.verts, indexLowerBound, indexUpperBound);
|
2014-03-23 15:34:04 +01:00
|
|
|
decodedVerts_ += vertexCount;
|
2013-11-10 15:22:24 +01:00
|
|
|
|
|
|
|
// 4. Advance indexgen vertex counter.
|
|
|
|
indexGen.Advance(vertexCount);
|
|
|
|
decodeCounter_ = lastMatch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-07 17:29:28 -07:00
|
|
|
inline u32 ComputeMiniHashRange(const void *ptr, size_t sz) {
|
|
|
|
// Switch to u32 units.
|
|
|
|
const u32 *p = (const u32 *)ptr;
|
|
|
|
sz >>= 2;
|
|
|
|
|
|
|
|
if (sz > 100) {
|
|
|
|
size_t step = sz / 4;
|
|
|
|
u32 hash = 0;
|
|
|
|
for (size_t i = 0; i < sz; i += step) {
|
2014-10-26 17:49:24 -07:00
|
|
|
hash += DoReliableHash32(p + i, 100, 0x3A44B9C4);
|
2014-09-07 17:29:28 -07:00
|
|
|
}
|
|
|
|
return hash;
|
|
|
|
} else {
|
|
|
|
return p[0] + p[sz - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 TransformDrawEngine::ComputeMiniHash() {
|
|
|
|
u32 fullhash = 0;
|
|
|
|
const int vertexSize = dec_->GetDecVtxFmt().stride;
|
|
|
|
const int indexSize = (dec_->VertexType() & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT ? 2 : 1;
|
|
|
|
|
|
|
|
int step;
|
|
|
|
if (numDrawCalls < 3) {
|
|
|
|
step = 1;
|
|
|
|
} else if (numDrawCalls < 8) {
|
|
|
|
step = 4;
|
|
|
|
} else {
|
|
|
|
step = numDrawCalls / 8;
|
|
|
|
}
|
|
|
|
for (int i = 0; i < numDrawCalls; i += step) {
|
|
|
|
const DeferredDrawCall &dc = drawCalls[i];
|
|
|
|
if (!dc.inds) {
|
|
|
|
fullhash += ComputeMiniHashRange(dc.verts, vertexSize * dc.vertexCount);
|
|
|
|
} else {
|
|
|
|
int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound;
|
|
|
|
fullhash += ComputeMiniHashRange((const u8 *)dc.verts + vertexSize * indexLowerBound, vertexSize * (indexUpperBound - indexLowerBound));
|
|
|
|
fullhash += ComputeMiniHashRange(dc.inds, indexSize * dc.vertexCount);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fullhash;
|
|
|
|
}
|
|
|
|
|
2014-09-07 17:28:12 -07:00
|
|
|
void TransformDrawEngine::MarkUnreliable(VertexArrayInfo *vai) {
|
|
|
|
vai->status = VertexArrayInfo::VAI_UNRELIABLE;
|
|
|
|
if (vai->vbo) {
|
|
|
|
FreeBuffer(vai->vbo);
|
|
|
|
vai->vbo = 0;
|
|
|
|
}
|
|
|
|
if (vai->ebo) {
|
|
|
|
FreeBuffer(vai->ebo);
|
|
|
|
vai->ebo = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-26 17:49:24 -07:00
|
|
|
ReliableHashType TransformDrawEngine::ComputeHash() {
|
|
|
|
ReliableHashType fullhash = 0;
|
2014-09-07 17:28:12 -07:00
|
|
|
const int vertexSize = dec_->GetDecVtxFmt().stride;
|
|
|
|
const int indexSize = (dec_->VertexType() & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT ? 2 : 1;
|
2013-01-19 17:05:08 +01:00
|
|
|
|
2013-02-06 00:42:06 +01:00
|
|
|
// TODO: Add some caps both for numDrawCalls and num verts to check?
|
2013-08-06 19:08:38 +02:00
|
|
|
// It is really very expensive to check all the vertex data so often.
|
2013-01-19 17:05:08 +01:00
|
|
|
for (int i = 0; i < numDrawCalls; i++) {
|
2013-10-29 12:14:09 +01:00
|
|
|
const DeferredDrawCall &dc = drawCalls[i];
|
|
|
|
if (!dc.inds) {
|
2014-03-25 00:21:04 -07:00
|
|
|
fullhash += DoReliableHash((const char *)dc.verts, vertexSize * dc.vertexCount, 0x1DE8CAC4);
|
2013-01-19 17:05:08 +01:00
|
|
|
} else {
|
2013-10-29 12:14:09 +01:00
|
|
|
int indexLowerBound = dc.indexLowerBound, indexUpperBound = dc.indexUpperBound;
|
|
|
|
int j = i + 1;
|
|
|
|
int lastMatch = i;
|
|
|
|
while (j < numDrawCalls) {
|
|
|
|
if (drawCalls[j].verts != dc.verts)
|
|
|
|
break;
|
|
|
|
indexLowerBound = std::min(indexLowerBound, (int)dc.indexLowerBound);
|
|
|
|
indexUpperBound = std::max(indexUpperBound, (int)dc.indexUpperBound);
|
|
|
|
lastMatch = j;
|
|
|
|
j++;
|
|
|
|
}
|
2013-04-14 09:56:16 +02:00
|
|
|
// This could get seriously expensive with sparse indices. Need to combine hashing ranges the same way
|
|
|
|
// we do when drawing.
|
2014-03-25 00:21:04 -07:00
|
|
|
fullhash += DoReliableHash((const char *)dc.verts + vertexSize * indexLowerBound,
|
2013-10-29 16:18:15 +01:00
|
|
|
vertexSize * (indexUpperBound - indexLowerBound), 0x029F3EE1);
|
2013-10-29 12:14:09 +01:00
|
|
|
// Hm, we will miss some indices when combining above, but meh, it should be fine.
|
2014-03-25 00:21:04 -07:00
|
|
|
fullhash += DoReliableHash((const char *)dc.inds, indexSize * dc.vertexCount, 0x955FD1CA);
|
2013-10-29 12:14:09 +01:00
|
|
|
i = lastMatch;
|
2012-12-21 18:46:15 +01:00
|
|
|
}
|
2013-01-19 17:05:08 +01:00
|
|
|
}
|
2013-10-09 23:09:16 +02:00
|
|
|
if (uvScale) {
|
2014-03-25 00:21:04 -07:00
|
|
|
fullhash += DoReliableHash(&uvScale[0], sizeof(uvScale[0]) * numDrawCalls, 0x0123e658);
|
2013-10-09 23:09:16 +02:00
|
|
|
}
|
2013-01-19 17:05:08 +01:00
|
|
|
|
|
|
|
return fullhash;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::ClearTrackedVertexArrays() {
|
|
|
|
for (auto vai = vai_.begin(); vai != vai_.end(); vai++) {
|
|
|
|
delete vai->second;
|
|
|
|
}
|
|
|
|
vai_.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void TransformDrawEngine::DecimateTrackedVertexArrays() {
|
2013-08-01 00:13:58 +02:00
|
|
|
if (--decimationCounter_ <= 0) {
|
|
|
|
decimationCounter_ = VERTEXCACHE_DECIMATION_INTERVAL;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-09-14 13:50:57 -07:00
|
|
|
const int threshold = gpuStats.numFlips - VAI_KILL_AGE;
|
|
|
|
const int unreliableThreshold = gpuStats.numFlips - VAI_UNRELIABLE_KILL_AGE;
|
2014-09-07 17:08:05 -07:00
|
|
|
int unreliableLeft = VAI_UNRELIABLE_KILL_MAX;
|
2013-01-19 17:05:08 +01:00
|
|
|
for (auto iter = vai_.begin(); iter != vai_.end(); ) {
|
2014-09-07 17:08:05 -07:00
|
|
|
bool kill;
|
|
|
|
if (iter->second->status == VertexArrayInfo::VAI_UNRELIABLE) {
|
|
|
|
// We limit killing unreliable so we don't rehash too often.
|
|
|
|
kill = iter->second->lastFrame < unreliableThreshold && --unreliableLeft >= 0;
|
|
|
|
} else {
|
|
|
|
kill = iter->second->lastFrame < threshold;
|
|
|
|
}
|
|
|
|
if (kill) {
|
2013-01-19 17:05:08 +01:00
|
|
|
delete iter->second;
|
|
|
|
vai_.erase(iter++);
|
2013-12-09 13:45:17 +01:00
|
|
|
} else {
|
2013-01-19 17:05:08 +01:00
|
|
|
++iter;
|
2013-12-09 13:45:17 +01:00
|
|
|
}
|
2012-12-21 18:46:15 +01:00
|
|
|
}
|
2012-12-21 19:16:17 +01:00
|
|
|
}
|
|
|
|
|
2013-01-19 19:22:15 +01:00
|
|
|
VertexArrayInfo::~VertexArrayInfo() {
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.arrayBuffer.unbind();
|
|
|
|
glstate.elementArrayBuffer.unbind();
|
2013-01-19 19:22:15 +01:00
|
|
|
if (vbo)
|
|
|
|
glDeleteBuffers(1, &vbo);
|
|
|
|
if (ebo)
|
|
|
|
glDeleteBuffers(1, &ebo);
|
|
|
|
}
|
|
|
|
|
2014-06-07 16:15:37 -07:00
|
|
|
GLuint TransformDrawEngine::AllocateBuffer() {
|
|
|
|
if (bufferNameCache_.empty()) {
|
|
|
|
bufferNameCache_.resize(VERTEXCACHE_NAME_CACHE_SIZE);
|
|
|
|
glGenBuffers(VERTEXCACHE_NAME_CACHE_SIZE, &bufferNameCache_[0]);
|
|
|
|
}
|
|
|
|
GLuint buf = bufferNameCache_.back();
|
|
|
|
bufferNameCache_.pop_back();
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2014-06-07 16:20:12 -07:00
|
|
|
void TransformDrawEngine::FreeBuffer(GLuint buf) {
|
|
|
|
// We can reuse buffers by setting new data on them.
|
|
|
|
bufferNameCache_.push_back(buf);
|
2014-06-07 16:28:24 -07:00
|
|
|
|
|
|
|
// But let's not keep too many around, will eat up memory.
|
|
|
|
if (bufferNameCache_.size() >= VERTEXCACHE_NAME_CACHE_FULL_SIZE) {
|
|
|
|
GLsizei extra = (GLsizei)bufferNameCache_.size() - VERTEXCACHE_NAME_CACHE_SIZE;
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.arrayBuffer.unbind();
|
|
|
|
glstate.elementArrayBuffer.unbind();
|
2014-06-07 16:28:24 -07:00
|
|
|
glDeleteBuffers(extra, &bufferNameCache_[VERTEXCACHE_NAME_CACHE_SIZE]);
|
|
|
|
bufferNameCache_.resize(VERTEXCACHE_NAME_CACHE_SIZE);
|
|
|
|
}
|
2014-06-07 16:20:12 -07:00
|
|
|
}
|
|
|
|
|
2013-08-11 01:25:14 +02:00
|
|
|
void TransformDrawEngine::DoFlush() {
|
2013-01-19 17:05:08 +01:00
|
|
|
gpuStats.numFlushes++;
|
2013-02-24 10:38:30 -08:00
|
|
|
gpuStats.numTrackedVertexArrays = (int)vai_.size();
|
2012-12-19 18:35:37 +01:00
|
|
|
|
2013-08-07 22:32:04 +02:00
|
|
|
// This is not done on every drawcall, we should collect vertex data
|
2012-12-20 14:10:42 +01:00
|
|
|
// until critical state changes. That's when we draw (flush).
|
2012-12-19 18:35:37 +01:00
|
|
|
|
2013-08-25 19:51:06 +02:00
|
|
|
GEPrimitiveType prim = prevPrim_;
|
2013-01-12 17:20:00 +01:00
|
|
|
ApplyDrawState(prim);
|
2012-12-20 14:10:42 +01:00
|
|
|
|
2014-03-24 10:55:07 +01:00
|
|
|
Shader *vshader = shaderManager_->ApplyVertexShader(prim, lastVType_);
|
2012-12-20 14:10:42 +01:00
|
|
|
|
2014-03-24 10:55:07 +01:00
|
|
|
if (vshader->UseHWTransform()) {
|
2013-01-19 19:22:15 +01:00
|
|
|
GLuint vbo = 0, ebo = 0;
|
|
|
|
int vertexCount = 0;
|
2014-09-18 00:40:25 +02:00
|
|
|
int maxIndex = 0; // Compiler warns about this because it's only used in the #ifdeffed out RangeElements path.
|
2013-01-20 21:52:54 +01:00
|
|
|
bool useElements = true;
|
2013-11-10 13:18:52 +01:00
|
|
|
|
2013-01-20 22:48:29 +01:00
|
|
|
// Cannot cache vertex data with morph enabled.
|
2013-11-10 13:18:52 +01:00
|
|
|
bool useCache = g_Config.bVertexCache && !(lastVType_ & GE_VTYPE_MORPHCOUNT_MASK);
|
|
|
|
// Also avoid caching when software skinning.
|
|
|
|
if (g_Config.bSoftwareSkinning && (lastVType_ & GE_VTYPE_WEIGHT_MASK))
|
|
|
|
useCache = false;
|
|
|
|
|
|
|
|
if (useCache) {
|
2014-03-23 01:51:51 +01:00
|
|
|
u32 id = dcid_;
|
2013-01-20 13:15:46 +01:00
|
|
|
auto iter = vai_.find(id);
|
|
|
|
VertexArrayInfo *vai;
|
2013-01-26 11:36:45 -08:00
|
|
|
if (iter != vai_.end()) {
|
2013-01-20 13:15:46 +01:00
|
|
|
// We've seen this before. Could have been a cached draw.
|
|
|
|
vai = iter->second;
|
|
|
|
} else {
|
|
|
|
vai = new VertexArrayInfo();
|
|
|
|
vai_[id] = vai;
|
|
|
|
}
|
2013-01-19 19:22:15 +01:00
|
|
|
|
2013-01-20 21:52:54 +01:00
|
|
|
switch (vai->status) {
|
2013-01-20 13:15:46 +01:00
|
|
|
case VertexArrayInfo::VAI_NEW:
|
|
|
|
{
|
|
|
|
// Haven't seen this one before.
|
2014-10-26 17:49:24 -07:00
|
|
|
ReliableHashType dataHash = ComputeHash();
|
2013-01-20 13:15:46 +01:00
|
|
|
vai->hash = dataHash;
|
2014-09-07 17:29:28 -07:00
|
|
|
vai->minihash = ComputeMiniHash();
|
2013-01-20 13:15:46 +01:00
|
|
|
vai->status = VertexArrayInfo::VAI_HASHING;
|
2013-02-11 23:41:31 -08:00
|
|
|
vai->drawsUntilNextFullHash = 0;
|
2013-01-20 13:15:46 +01:00
|
|
|
DecodeVerts(); // writes to indexGen
|
2013-07-22 19:10:19 +02:00
|
|
|
vai->numVerts = indexGen.VertexCount();
|
|
|
|
vai->prim = indexGen.Prim();
|
2013-10-08 22:59:40 +02:00
|
|
|
vai->maxIndex = indexGen.MaxIndex();
|
2014-03-24 11:19:11 +01:00
|
|
|
vai->flags = gstate_c.vertexFullAlpha ? VAI_FLAG_VERTEXFULLALPHA : 0;
|
|
|
|
|
2013-01-20 13:15:46 +01:00
|
|
|
goto rotateVBO;
|
|
|
|
}
|
2013-01-19 19:22:15 +01:00
|
|
|
|
2013-01-20 13:15:46 +01:00
|
|
|
// Hashing - still gaining confidence about the buffer.
|
|
|
|
// But if we get this far it's likely to be worth creating a vertex buffer.
|
|
|
|
case VertexArrayInfo::VAI_HASHING:
|
|
|
|
{
|
|
|
|
vai->numDraws++;
|
2013-08-07 22:32:04 +02:00
|
|
|
if (vai->lastFrame != gpuStats.numFlips) {
|
2013-02-10 12:27:43 -08:00
|
|
|
vai->numFrames++;
|
|
|
|
}
|
2013-02-11 23:41:31 -08:00
|
|
|
if (vai->drawsUntilNextFullHash == 0) {
|
2014-09-07 17:34:29 -07:00
|
|
|
// Let's try to skip a full hash if mini would fail.
|
|
|
|
const u32 newMiniHash = ComputeMiniHash();
|
2014-10-26 17:49:24 -07:00
|
|
|
ReliableHashType newHash = vai->hash;
|
2014-09-07 17:34:29 -07:00
|
|
|
if (newMiniHash == vai->minihash) {
|
|
|
|
newHash = ComputeHash();
|
|
|
|
}
|
|
|
|
if (newMiniHash != vai->minihash || newHash != vai->hash) {
|
2014-09-07 17:28:12 -07:00
|
|
|
MarkUnreliable(vai);
|
2013-02-06 00:42:06 +01:00
|
|
|
DecodeVerts();
|
|
|
|
goto rotateVBO;
|
2013-01-20 21:52:54 +01:00
|
|
|
}
|
2014-09-07 17:36:19 -07:00
|
|
|
if (vai->numVerts > 64) {
|
|
|
|
// exponential backoff up to 16 draws, then every 32
|
|
|
|
vai->drawsUntilNextFullHash = std::min(32, vai->numFrames);
|
2013-02-12 00:02:53 -08:00
|
|
|
} else {
|
|
|
|
// Lower numbers seem much more likely to change.
|
2013-02-12 00:17:12 -08:00
|
|
|
vai->drawsUntilNextFullHash = 0;
|
2013-02-12 00:02:53 -08:00
|
|
|
}
|
|
|
|
// TODO: tweak
|
|
|
|
//if (vai->numFrames > 1000) {
|
|
|
|
// vai->status = VertexArrayInfo::VAI_RELIABLE;
|
|
|
|
//}
|
2013-02-06 00:42:06 +01:00
|
|
|
} else {
|
2013-02-11 23:41:31 -08:00
|
|
|
vai->drawsUntilNextFullHash--;
|
2014-09-07 17:29:28 -07:00
|
|
|
u32 newMiniHash = ComputeMiniHash();
|
|
|
|
if (newMiniHash != vai->minihash) {
|
|
|
|
MarkUnreliable(vai);
|
|
|
|
DecodeVerts();
|
|
|
|
goto rotateVBO;
|
|
|
|
}
|
2013-01-19 19:22:15 +01:00
|
|
|
}
|
2013-02-06 00:42:06 +01:00
|
|
|
|
2013-01-20 13:15:46 +01:00
|
|
|
if (vai->vbo == 0) {
|
2013-01-20 21:52:54 +01:00
|
|
|
DecodeVerts();
|
2013-01-20 13:15:46 +01:00
|
|
|
vai->numVerts = indexGen.VertexCount();
|
|
|
|
vai->prim = indexGen.Prim();
|
2013-10-08 22:59:40 +02:00
|
|
|
vai->maxIndex = indexGen.MaxIndex();
|
2014-03-25 08:19:14 -07:00
|
|
|
vai->flags = gstate_c.vertexFullAlpha ? VAI_FLAG_VERTEXFULLALPHA : 0;
|
2013-01-20 22:42:11 +01:00
|
|
|
useElements = !indexGen.SeenOnlyPurePrims();
|
2013-04-20 23:35:53 +02:00
|
|
|
if (!useElements && indexGen.PureCount()) {
|
|
|
|
vai->numVerts = indexGen.PureCount();
|
|
|
|
}
|
2013-12-09 13:45:17 +01:00
|
|
|
|
2014-06-07 16:15:37 -07:00
|
|
|
vai->vbo = AllocateBuffer();
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.arrayBuffer.bind(vai->vbo);
|
2013-03-24 12:28:42 +01:00
|
|
|
glBufferData(GL_ARRAY_BUFFER, dec_->GetDecVtxFmt().stride * indexGen.MaxIndex(), decoded, GL_STATIC_DRAW);
|
2013-01-20 13:15:46 +01:00
|
|
|
// If there's only been one primitive type, and it's either TRIANGLES, LINES or POINTS,
|
|
|
|
// there is no need for the index buffer we built. We can then use glDrawArrays instead
|
|
|
|
// for a very minor speed boost.
|
2013-01-20 22:42:11 +01:00
|
|
|
if (useElements) {
|
2014-06-07 16:15:37 -07:00
|
|
|
vai->ebo = AllocateBuffer();
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.elementArrayBuffer.bind(vai->ebo);
|
2013-01-20 13:15:46 +01:00
|
|
|
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(short) * indexGen.VertexCount(), (GLvoid *)decIndex, GL_STATIC_DRAW);
|
2013-01-20 21:52:54 +01:00
|
|
|
} else {
|
|
|
|
vai->ebo = 0;
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.elementArrayBuffer.bind(vai->ebo);
|
2013-01-20 13:15:46 +01:00
|
|
|
}
|
|
|
|
} else {
|
2013-02-06 00:42:06 +01:00
|
|
|
gpuStats.numCachedDrawCalls++;
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.arrayBuffer.bind(vai->vbo);
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.elementArrayBuffer.bind(vai->ebo);
|
2013-01-20 22:42:11 +01:00
|
|
|
useElements = vai->ebo ? true : false;
|
2013-01-25 00:36:59 +01:00
|
|
|
gpuStats.numCachedVertsDrawn += vai->numVerts;
|
2014-03-25 08:19:14 -07:00
|
|
|
gstate_c.vertexFullAlpha = vai->flags & VAI_FLAG_VERTEXFULLALPHA;
|
2013-01-19 19:22:15 +01:00
|
|
|
}
|
2013-01-20 13:15:46 +01:00
|
|
|
vbo = vai->vbo;
|
|
|
|
ebo = vai->ebo;
|
|
|
|
vertexCount = vai->numVerts;
|
2013-10-08 22:59:40 +02:00
|
|
|
maxIndex = vai->maxIndex;
|
2013-08-25 19:51:06 +02:00
|
|
|
prim = static_cast<GEPrimitiveType>(vai->prim);
|
2013-01-20 13:15:46 +01:00
|
|
|
break;
|
2013-01-19 19:22:15 +01:00
|
|
|
}
|
2013-01-20 13:15:46 +01:00
|
|
|
|
|
|
|
// Reliable - we don't even bother hashing anymore. Right now we don't go here until after a very long time.
|
|
|
|
case VertexArrayInfo::VAI_RELIABLE:
|
|
|
|
{
|
|
|
|
vai->numDraws++;
|
2013-08-07 22:32:04 +02:00
|
|
|
if (vai->lastFrame != gpuStats.numFlips) {
|
2013-02-10 12:27:43 -08:00
|
|
|
vai->numFrames++;
|
|
|
|
}
|
2013-01-20 13:15:46 +01:00
|
|
|
gpuStats.numCachedDrawCalls++;
|
2013-01-25 00:36:59 +01:00
|
|
|
gpuStats.numCachedVertsDrawn += vai->numVerts;
|
2013-01-20 13:15:46 +01:00
|
|
|
vbo = vai->vbo;
|
|
|
|
ebo = vai->ebo;
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.arrayBuffer.bind(vbo);
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.elementArrayBuffer.bind(ebo);
|
2013-01-20 13:15:46 +01:00
|
|
|
vertexCount = vai->numVerts;
|
2013-10-08 22:59:40 +02:00
|
|
|
maxIndex = vai->maxIndex;
|
2013-08-25 19:51:06 +02:00
|
|
|
prim = static_cast<GEPrimitiveType>(vai->prim);
|
2014-03-24 11:19:11 +01:00
|
|
|
|
|
|
|
gstate_c.vertexFullAlpha = vai->flags & VAI_FLAG_VERTEXFULLALPHA;
|
2013-01-20 13:15:46 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case VertexArrayInfo::VAI_UNRELIABLE:
|
|
|
|
{
|
|
|
|
vai->numDraws++;
|
2013-08-07 22:32:04 +02:00
|
|
|
if (vai->lastFrame != gpuStats.numFlips) {
|
2013-02-10 12:27:43 -08:00
|
|
|
vai->numFrames++;
|
|
|
|
}
|
2013-01-20 13:15:46 +01:00
|
|
|
DecodeVerts();
|
|
|
|
goto rotateVBO;
|
|
|
|
}
|
|
|
|
}
|
2013-02-11 23:29:49 -08:00
|
|
|
|
2013-08-07 22:32:04 +02:00
|
|
|
vai->lastFrame = gpuStats.numFlips;
|
2013-01-20 13:15:46 +01:00
|
|
|
} else {
|
|
|
|
DecodeVerts();
|
2013-12-09 13:45:17 +01:00
|
|
|
|
2013-01-19 19:22:15 +01:00
|
|
|
rotateVBO:
|
2013-01-25 00:36:59 +01:00
|
|
|
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
2013-01-20 21:52:54 +01:00
|
|
|
useElements = !indexGen.SeenOnlyPurePrims();
|
2013-01-28 19:04:12 +01:00
|
|
|
vertexCount = indexGen.VertexCount();
|
2013-10-08 22:59:40 +02:00
|
|
|
maxIndex = indexGen.MaxIndex();
|
2013-04-20 23:35:53 +02:00
|
|
|
if (!useElements && indexGen.PureCount()) {
|
|
|
|
vertexCount = indexGen.PureCount();
|
|
|
|
}
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.arrayBuffer.unbind();
|
|
|
|
glstate.elementArrayBuffer.unbind();
|
2013-08-09 05:12:26 -04:00
|
|
|
|
2013-01-20 21:52:54 +01:00
|
|
|
prim = indexGen.Prim();
|
2013-01-19 19:22:15 +01:00
|
|
|
}
|
2013-12-09 13:45:17 +01:00
|
|
|
|
2013-11-14 11:01:31 +01:00
|
|
|
VERBOSE_LOG(G3D, "Flush prim %i! %i verts in one go", prim, vertexCount);
|
2014-03-24 17:33:20 +01:00
|
|
|
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
|
|
|
if (gstate.isModeThrough()) {
|
|
|
|
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255);
|
|
|
|
} else {
|
|
|
|
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255);
|
|
|
|
}
|
2013-01-19 19:22:15 +01:00
|
|
|
|
2014-09-10 23:43:48 -07:00
|
|
|
ApplyDrawStateLate();
|
2014-03-24 10:55:07 +01:00
|
|
|
LinkedShader *program = shaderManager_->ApplyFragmentShader(vshader, prim, lastVType_);
|
2013-03-24 12:28:42 +01:00
|
|
|
SetupDecFmtForDraw(program, dec_->GetDecVtxFmt(), vbo ? 0 : decoded);
|
2014-03-24 10:55:07 +01:00
|
|
|
|
2013-01-20 21:52:54 +01:00
|
|
|
if (useElements) {
|
2013-11-14 17:33:43 +01:00
|
|
|
#if 1 // USING_GLES2
|
2013-01-20 21:52:54 +01:00
|
|
|
glDrawElements(glprim[prim], vertexCount, GL_UNSIGNED_SHORT, ebo ? 0 : (GLvoid*)decIndex);
|
2013-10-08 22:59:40 +02:00
|
|
|
#else
|
|
|
|
glDrawRangeElements(glprim[prim], 0, maxIndex, vertexCount, GL_UNSIGNED_SHORT, ebo ? 0 : (GLvoid*)decIndex);
|
|
|
|
#endif
|
2013-01-20 21:52:54 +01:00
|
|
|
} else {
|
|
|
|
glDrawArrays(glprim[prim], 0, vertexCount);
|
2012-12-26 08:54:33 +01:00
|
|
|
}
|
2012-12-20 14:10:42 +01:00
|
|
|
} else {
|
2013-01-19 19:22:15 +01:00
|
|
|
DecodeVerts();
|
2014-03-24 17:33:20 +01:00
|
|
|
bool hasColor = (lastVType_ & GE_VTYPE_COL_MASK) != GE_VTYPE_COL_NONE;
|
|
|
|
if (gstate.isModeThrough()) {
|
|
|
|
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && (hasColor || gstate.getMaterialAmbientA() == 255);
|
|
|
|
} else {
|
|
|
|
gstate_c.vertexFullAlpha = gstate_c.vertexFullAlpha && ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255);
|
|
|
|
}
|
2014-03-24 11:19:11 +01:00
|
|
|
|
2014-09-10 23:43:48 -07:00
|
|
|
ApplyDrawStateLate();
|
2014-03-24 10:55:07 +01:00
|
|
|
LinkedShader *program = shaderManager_->ApplyFragmentShader(vshader, prim, lastVType_);
|
2013-01-25 00:36:59 +01:00
|
|
|
gpuStats.numUncachedVertsDrawn += indexGen.VertexCount();
|
2013-01-19 19:22:15 +01:00
|
|
|
prim = indexGen.Prim();
|
2013-04-21 19:28:24 +02:00
|
|
|
// Undo the strip optimization, not supported by the SW code yet.
|
|
|
|
if (prim == GE_PRIM_TRIANGLE_STRIP)
|
|
|
|
prim = GE_PRIM_TRIANGLES;
|
2013-01-19 19:22:15 +01:00
|
|
|
|
2014-09-13 13:03:37 +02:00
|
|
|
TransformedVertex *drawBuffer = NULL;
|
|
|
|
int numTrans;
|
|
|
|
bool drawIndexed = false;
|
|
|
|
u16 *inds = decIndex;
|
|
|
|
SoftwareTransformResult result;
|
|
|
|
memset(&result, 0, sizeof(result));
|
|
|
|
|
|
|
|
SoftwareTransform(
|
2014-09-13 13:27:42 +02:00
|
|
|
prim, decoded, indexGen.VertexCount(),
|
2015-01-15 12:26:35 -08:00
|
|
|
dec_->VertexType(), inds, GE_VTYPE_IDX_16BIT, dec_->GetDecVtxFmt(),
|
2014-09-13 13:27:42 +02:00
|
|
|
indexGen.MaxIndex(), framebufferManager_, textureCache_, transformed, transformedExpanded, drawBuffer, numTrans, drawIndexed, &result);
|
2014-09-13 13:03:37 +02:00
|
|
|
|
|
|
|
if (result.action == SW_DRAW_PRIMITIVES) {
|
|
|
|
if (result.setStencil) {
|
|
|
|
glstate.stencilFunc.set(GL_ALWAYS, result.stencilValue, 255);
|
|
|
|
}
|
|
|
|
const int vertexSize = sizeof(transformed[0]);
|
|
|
|
|
|
|
|
bool doTextureProjection = gstate.getUVGenMode() == GE_TEXMAP_TEXTURE_MATRIX;
|
2015-01-11 16:56:29 -08:00
|
|
|
glstate.arrayBuffer.unbind();
|
2015-01-11 17:03:45 -08:00
|
|
|
glstate.elementArrayBuffer.unbind();
|
2014-09-13 13:03:37 +02:00
|
|
|
glVertexAttribPointer(ATTR_POSITION, 4, GL_FLOAT, GL_FALSE, vertexSize, drawBuffer);
|
|
|
|
int attrMask = program->attrMask;
|
|
|
|
if (attrMask & (1 << ATTR_TEXCOORD)) glVertexAttribPointer(ATTR_TEXCOORD, doTextureProjection ? 3 : 2, GL_FLOAT, GL_FALSE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, u));
|
|
|
|
if (attrMask & (1 << ATTR_COLOR0)) glVertexAttribPointer(ATTR_COLOR0, 4, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, color0));
|
|
|
|
if (attrMask & (1 << ATTR_COLOR1)) glVertexAttribPointer(ATTR_COLOR1, 3, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + offsetof(TransformedVertex, color1));
|
|
|
|
if (drawIndexed) {
|
|
|
|
#if 1 // USING_GLES2
|
|
|
|
glDrawElements(glprim[prim], numTrans, GL_UNSIGNED_SHORT, inds);
|
|
|
|
#else
|
|
|
|
glDrawRangeElements(glprim[prim], 0, indexGen.MaxIndex(), numTrans, GL_UNSIGNED_SHORT, inds);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
glDrawArrays(glprim[prim], 0, numTrans);
|
|
|
|
}
|
|
|
|
} else if (result.action == SW_CLEAR) {
|
|
|
|
u32 clearColor = result.color;
|
|
|
|
float clearDepth = result.depth;
|
|
|
|
const float col[4] = {
|
|
|
|
((clearColor & 0xFF)) / 255.0f,
|
|
|
|
((clearColor & 0xFF00) >> 8) / 255.0f,
|
|
|
|
((clearColor & 0xFF0000) >> 16) / 255.0f,
|
|
|
|
((clearColor & 0xFF000000) >> 24) / 255.0f,
|
|
|
|
};
|
|
|
|
|
|
|
|
bool colorMask = gstate.isClearModeColorMask();
|
|
|
|
bool alphaMask = gstate.isClearModeAlphaMask();
|
|
|
|
bool depthMask = gstate.isClearModeDepthMask();
|
|
|
|
if (depthMask) {
|
|
|
|
framebufferManager_->SetDepthUpdated();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Note that scissor may still apply while clearing. Turn off other tests for the clear.
|
|
|
|
glstate.stencilTest.disable();
|
|
|
|
glstate.stencilMask.set(0xFF);
|
|
|
|
glstate.depthTest.disable();
|
|
|
|
|
|
|
|
GLbitfield target = 0;
|
|
|
|
if (colorMask || alphaMask) target |= GL_COLOR_BUFFER_BIT;
|
|
|
|
if (alphaMask) target |= GL_STENCIL_BUFFER_BIT;
|
|
|
|
if (depthMask) target |= GL_DEPTH_BUFFER_BIT;
|
|
|
|
|
2014-09-14 08:00:35 -07:00
|
|
|
glstate.colorMask.set(colorMask, colorMask, colorMask, alphaMask);
|
2014-09-13 13:03:37 +02:00
|
|
|
glClearColor(col[0], col[1], col[2], col[3]);
|
|
|
|
#ifdef USING_GLES2
|
|
|
|
glClearDepthf(clearDepth);
|
|
|
|
#else
|
|
|
|
glClearDepth(clearDepth);
|
|
|
|
#endif
|
|
|
|
// Stencil takes alpha.
|
|
|
|
glClearStencil(clearColor >> 24);
|
|
|
|
glClear(target);
|
|
|
|
framebufferManager_->SetColorUpdated();
|
|
|
|
}
|
2012-12-20 14:10:42 +01:00
|
|
|
}
|
2012-12-19 18:35:37 +01:00
|
|
|
|
2014-10-19 20:25:04 +02:00
|
|
|
gpuStats.numDrawCalls += numDrawCalls;
|
|
|
|
gpuStats.numVertsSubmitted += vertexCountInDrawCalls;
|
|
|
|
|
2012-12-21 19:16:17 +01:00
|
|
|
indexGen.Reset();
|
2014-03-23 15:34:04 +01:00
|
|
|
decodedVerts_ = 0;
|
2013-01-19 17:05:08 +01:00
|
|
|
numDrawCalls = 0;
|
2013-10-27 14:43:58 -07:00
|
|
|
vertexCountInDrawCalls = 0;
|
2013-11-10 15:22:24 +01:00
|
|
|
decodeCounter_ = 0;
|
2014-03-23 01:51:51 +01:00
|
|
|
dcid_ = 0;
|
2013-08-25 19:51:06 +02:00
|
|
|
prevPrim_ = GE_PRIM_INVALID;
|
2014-03-24 11:19:11 +01:00
|
|
|
gstate_c.vertexFullAlpha = true;
|
2014-06-11 22:21:08 -07:00
|
|
|
framebufferManager_->SetColorUpdated();
|
2013-09-22 00:18:46 -07:00
|
|
|
|
2014-02-08 10:29:22 -08:00
|
|
|
#ifndef MOBILE_DEVICE
|
2013-09-22 00:18:46 -07:00
|
|
|
host->GPUNotifyDraw();
|
|
|
|
#endif
|
2012-12-21 21:49:09 +01:00
|
|
|
}
|
2013-09-24 13:58:14 +02:00
|
|
|
|
2014-06-28 21:37:41 -07:00
|
|
|
void TransformDrawEngine::Resized() {
|
|
|
|
decJitCache_->Clear();
|
|
|
|
lastVType_ = -1;
|
|
|
|
dec_ = NULL;
|
|
|
|
for (auto iter = decoderMap_.begin(); iter != decoderMap_.end(); iter++) {
|
|
|
|
delete iter->second;
|
|
|
|
}
|
|
|
|
decoderMap_.clear();
|
2014-06-28 21:51:25 -07:00
|
|
|
|
|
|
|
if (g_Config.bPrescaleUV && !uvScale) {
|
|
|
|
uvScale = new UVScale[MAX_DEFERRED_DRAW_CALLS];
|
2014-06-29 15:45:55 -07:00
|
|
|
} else if (!g_Config.bPrescaleUV && uvScale) {
|
|
|
|
delete uvScale;
|
|
|
|
uvScale = 0;
|
2014-06-28 21:51:25 -07:00
|
|
|
}
|
2014-06-28 21:37:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-29 16:51:38 -07:00
|
|
|
bool TransformDrawEngine::IsCodePtrVertexDecoder(const u8 *ptr) const {
|
|
|
|
return decJitCache_->IsInSpace(ptr);
|
|
|
|
}
|