Use unordered_map where it makes sense. Very tiny speed boost?

Also some microoptimizations.
This commit is contained in:
Henrik Rydgard 2014-10-19 21:11:09 +02:00
parent 7cb5e7f53f
commit e22fed8b9f
6 changed files with 28 additions and 20 deletions

View File

@ -732,19 +732,22 @@ void DIRECTX9_GPU::Execute_Prim(u32 op, u32 diff) {
return;
}
if (!Memory::IsValidAddress(gstate_c.vertexAddr)) {
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", gstate_c.vertexAddr);
u32 vertexAddr = gstate_c.vertexAddr;
if (!Memory::IsValidAddress(vertexAddr)) {
ERROR_LOG_REPORT(G3D, "Bad vertex address %08x!", vertexAddr);
return;
}
void *verts = Memory::GetPointerUnchecked(gstate_c.vertexAddr);
void *verts = Memory::GetPointerUnchecked(vertexAddr);
void *inds = 0;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
if (!Memory::IsValidAddress(gstate_c.indexAddr)) {
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", gstate_c.indexAddr);
u32 vertexType = gstate.vertType;
if ((vertexType & GE_VTYPE_IDX_MASK) != GE_VTYPE_IDX_NONE) {
u32 indexAddr = gstate_c.indexAddr;
if (!Memory::IsValidAddress(indexAddr)) {
ERROR_LOG_REPORT(G3D, "Bad index address %08x!", indexAddr);
return;
}
inds = Memory::GetPointerUnchecked(gstate_c.indexAddr);
inds = Memory::GetPointerUnchecked(indexAddr);
}
#ifndef MOBILE_DEVICE
@ -754,18 +757,18 @@ void DIRECTX9_GPU::Execute_Prim(u32 op, u32 diff) {
#endif
int bytesRead = 0;
transformDraw_.SubmitPrim(verts, inds, prim, count, gstate.vertType, &bytesRead);
transformDraw_.SubmitPrim(verts, inds, prim, count, vertexType, &bytesRead);
int vertexCost = transformDraw_.EstimatePerVertexCost();
gpuStats.vertexGPUCycles += vertexCost * count;
cyclesExecuted += vertexCost * count;
int vertexCost = transformDraw_.EstimatePerVertexCost() * count;
gpuStats.vertexGPUCycles += vertexCost;
cyclesExecuted += vertexCost;
// 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.
// The VADDR/IADDR registers are NOT updated.
if (inds) {
int indexSize = 1;
if ((gstate.vertType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
if ((vertexType & GE_VTYPE_IDX_MASK) == GE_VTYPE_IDX_16BIT)
indexSize = 2;
gstate_c.indexAddr += count * indexSize;
} else {

View File

@ -17,6 +17,8 @@
#pragma once
#include <map>
#include "../Globals.h"
#include "helper/global.h"
#include "helper/fbo.h"
@ -155,6 +157,7 @@ public:
void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight);
private:
// Can't be unordered_map, we use lower_bound ... although for some reason that compiles on MSVC.
typedef std::map<u64, TexCacheEntry> TexCache;
void Decimate(); // Run this once per frame to get rid of old textures.

View File

@ -17,7 +17,7 @@
#pragma once
#include <map>
#include <unordered_map>
#include <d3d9.h>
@ -215,7 +215,7 @@ private:
GEPrimitiveType prevPrim_;
// Cached vertex decoders
std::map<u32, VertexDecoder *> decoderMap_;
std::unordered_map<u32, VertexDecoder *> decoderMap_;
VertexDecoder *dec_;
VertexDecoderJitCache *decJitCache_;
u32 lastVType_;
@ -223,8 +223,8 @@ private:
TransformedVertex *transformed;
TransformedVertex *transformedExpanded;
std::map<u32, VertexArrayInfoDX9 *> vai_;
std::map<u32, IDirect3DVertexDeclaration9 *> vertexDeclMap_;
std::unordered_map<u32, VertexArrayInfoDX9 *> vai_;
std::unordered_map<u32, IDirect3DVertexDeclaration9 *> vertexDeclMap_;
// Fixed index buffer for easy quad generation from spline/bezier
u16 *quadIndices_;

View File

@ -15,7 +15,6 @@
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <map>
#include <algorithm>
#include <cstring>

View File

@ -17,6 +17,8 @@
#pragma once
#include <map>
#include "gfx_es2/fbo.h"
#include "gfx_es2/gpu_features.h"
@ -171,6 +173,7 @@ public:
void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight);
private:
// Can't be unordered_map, we use lower_bound ... although for some reason that compiles on MSVC.
typedef std::map<u64, TexCacheEntry> TexCache;
void Decimate(); // Run this once per frame to get rid of old textures.

View File

@ -17,7 +17,7 @@
#pragma once
#include <map>
#include <unordered_map>
#include "GPU/Common/GPUDebugInterface.h"
#include "GPU/Common/IndexGenerator.h"
@ -212,7 +212,7 @@ private:
GEPrimitiveType prevPrim_;
// Cached vertex decoders
std::map<u32, VertexDecoder *> decoderMap_;
std::unordered_map<u32, VertexDecoder *> decoderMap_;
VertexDecoder *dec_;
VertexDecoderJitCache *decJitCache_;
u32 lastVType_;
@ -220,7 +220,7 @@ private:
TransformedVertex *transformed;
TransformedVertex *transformedExpanded;
std::map<u32, VertexArrayInfo *> vai_;
std::unordered_map<u32, VertexArrayInfo *> vai_;
// Fixed index buffer for easy quad generation from spline/bezier
u16 *quadIndices_;