Rename gpuStats.numFrames to numVBlanks. Switch to using numFlips for things like cache expirations.

This commit is contained in:
Henrik Rydgard 2013-08-07 22:32:04 +02:00
parent 8714240519
commit 51ffdfa132
9 changed files with 81 additions and 77 deletions

View File

@ -691,7 +691,7 @@ void PSPOskDialog::RenderKeyboard()
if(isCombinated == true)
{
float animStep = (float)(gpuStats.numFrames % 40) / 20.0f;
float animStep = (float)(gpuStats.numVBlanks % 40) / 20.0f;
// Fade in and out the next character so they know it's not part of the string yet.
u32 alpha = (0.5f - (cosf(animStep * M_PI) / 2.0f)) * 128 + 127;
color = CalcFadedColor((alpha << 24) | 0xFFFFFF);

View File

@ -108,7 +108,6 @@ static double fpsHistory[120];
static size_t fpsHistoryPos = 0;
static size_t fpsHistoryValid = 0;
static int lastNumFlips = 0;
static int numFlips = 0;
static float flips = 0.0f;
static u64 lastFlipCycles = 0;
@ -117,7 +116,7 @@ void hleLeaveVblank(u64 userdata, int cyclesLate);
void hleAfterFlip(u64 userdata, int cyclesLate);
void __DisplayInit() {
gpuStats.reset();
gpuStats.Reset();
hasSetMode = false;
mode = 0;
resumeMode = 0;
@ -231,12 +230,12 @@ void CalculateFPS()
if (now >= lastFpsTime + 1.0)
{
double frames = (gpuStats.numFrames - lastFpsFrame);
double frames = (gpuStats.numVBlanks - lastFpsFrame);
fps = frames / (now - lastFpsTime);
flips = 60.0 * (double) (numFlips - lastNumFlips) / frames;
flips = 60.0 * (double) (gpuStats.numFlips - lastNumFlips) / frames;
lastFpsFrame = gpuStats.numFrames;
lastNumFlips = numFlips;
lastFpsFrame = gpuStats.numVBlanks;
lastNumFlips = gpuStats.numFlips;
lastFpsTime = now;
fpsHistory[fpsHistoryPos++] = fps;
@ -245,8 +244,7 @@ void CalculateFPS()
}
}
void __DisplayGetDebugStats(char stats[2048])
{
void __DisplayGetDebugStats(char stats[2048]) {
gpu->UpdateStats();
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
@ -270,7 +268,7 @@ void __DisplayGetDebugStats(char stats[2048])
"Vertex shaders loaded: %i\n"
"Fragment shaders loaded: %i\n"
"Combined shaders loaded: %i\n",
gpuStats.numFrames,
gpuStats.numVBlanks,
gpuStats.msProcessingDisplayLists * 1000.0f,
kernelStats.msInSyscalls * 1000.0f,
kernelStats.slowestSyscallName ? kernelStats.slowestSyscallName : "(none)",
@ -295,7 +293,7 @@ void __DisplayGetDebugStats(char stats[2048])
gpuStats.numShaders
);
gpuStats.resetFrame();
gpuStats.ResetFrame();
kernelStats.ResetFrame();
}
@ -407,12 +405,15 @@ void hleEnterVblank(u64 userdata, int cyclesLate) {
// TODO: Should this be done here or in hleLeaveVblank?
if (framebufIsLatched) {
DEBUG_LOG(HLE, "Setting latched framebuffer %08x (prev: %08x)", latchedFramebuf.topaddr, framebuf.topaddr);
if (latchedFramebuf.topaddr != framebuf.topaddr) {
framebuf = latchedFramebuf;
framebufIsLatched = false;
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
gpuStats.numFlips++;
}
}
gpuStats.numFrames++;
gpuStats.numVBlanks++;
if (g_Config.iShowFPSCounter) {
CalculateFPS();
@ -498,7 +499,6 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync)
}
if (topaddr != framebuf.topaddr) {
++numFlips;
if (g_Config.iForceMaxEmulatedFPS) {
u64 now = CoreTiming::GetTicks();
u64 expected = msToCycles(1000) / g_Config.iForceMaxEmulatedFPS;
@ -512,8 +512,11 @@ u32 sceDisplaySetFramebuf(u32 topaddr, int linesize, int pixelformat, int sync)
if (sync == PSP_DISPLAY_SETBUF_IMMEDIATE) {
// Write immediately to the current framebuffer parameters
if (topaddr != 0) {
if (topaddr != framebuf.topaddr) {
framebuf = fbstate;
gpu->SetDisplayFramebuffer(framebuf.topaddr, framebuf.pspFramebufLinesize, framebuf.pspFramebufFormat);
gpuStats.numFlips++;
}
} else {
WARN_LOG(HLE, "%s: PSP_DISPLAY_SETBUF_IMMEDIATE without topaddr?", __FUNCTION__);
}

View File

@ -429,7 +429,7 @@ void FramebufferManager::DestroyFramebuf(VirtualFramebuffer *v) {
void FramebufferManager::SetRenderFrameBuffer() {
if (!gstate_c.framebufChanged && currentRenderVfb_) {
currentRenderVfb_->last_frame_used = gpuStats.numFrames;
currentRenderVfb_->last_frame_used = gpuStats.numVBlanks;
return;
}
gstate_c.framebufChanged = false;
@ -536,8 +536,8 @@ void FramebufferManager::SetRenderFrameBuffer() {
textureCache_->NotifyFramebuffer(vfb->fb_address, vfb, NOTIFY_FB_CREATED);
vfb->last_frame_used = gpuStats.numFrames;
frameLastFramebufUsed = gpuStats.numFrames;
vfb->last_frame_used = gpuStats.numFlips;
frameLastFramebufUsed = gpuStats.numFlips;
vfbs_.push_back(vfb);
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@ -554,8 +554,8 @@ void FramebufferManager::SetRenderFrameBuffer() {
DEBUG_LOG(HLE, "Switching render target to FBO for %08x: %i x %i x %i ", vfb->fb_address, vfb->width, vfb->height, vfb->format);
vfb->usageFlags |= FB_USAGE_RENDERTARGET;
gstate_c.textureChanged = true;
vfb->last_frame_used = gpuStats.numFrames;
frameLastFramebufUsed = gpuStats.numFrames;
vfb->last_frame_used = gpuStats.numFlips;
frameLastFramebufUsed = gpuStats.numFlips;
vfb->dirtyAfterDisplay = true;
if (useBufferedRendering_) {
@ -595,7 +595,7 @@ void FramebufferManager::SetRenderFrameBuffer() {
// to it. This broke stuff before, so now it only clears on the first use of an
// FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs
// performance-crushing framebuffer reloads from RAM, but we'll have to live with that.
if (vfb->last_frame_used != gpuStats.numFrames) {
if (vfb->last_frame_used != gpuStats.numFlips) {
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0,0,0,1);
@ -604,8 +604,8 @@ void FramebufferManager::SetRenderFrameBuffer() {
#endif
currentRenderVfb_ = vfb;
} else {
vfb->last_frame_used = gpuStats.numFrames;
frameLastFramebufUsed = gpuStats.numFrames;
vfb->last_frame_used = gpuStats.numFlips;
frameLastFramebufUsed = gpuStats.numFlips;
}
// ugly...
@ -754,7 +754,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) {
}
}
nvfb->last_frame_used = gpuStats.numFrames;
nvfb->last_frame_used = gpuStats.numFlips;
bvfbs_.push_back(nvfb);
glstate.depthWrite.set(GL_TRUE);
@ -764,7 +764,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) {
glEnable(GL_DITHER);
} else {
nvfb->usageFlags |= FB_USAGE_RENDERTARGET;
nvfb->last_frame_used = gpuStats.numFrames;
nvfb->last_frame_used = gpuStats.numFlips;
nvfb->dirtyAfterDisplay = true;
if (useBufferedRendering_) {
@ -775,7 +775,7 @@ void FramebufferManager::ReadFramebufferToMemory(VirtualFramebuffer *vfb) {
// to it. This broke stuff before, so now it only clears on the first use of an
// FBO in a frame. This means that some games won't be able to avoid the on-some-GPUs
// performance-crushing framebuffer reloads from RAM, but we'll have to live with that.
if (nvfb->last_frame_used != gpuStats.numFrames) {
if (nvfb->last_frame_used != gpuStats.numFlips) {
glstate.depthWrite.set(GL_TRUE);
glstate.colorMask.set(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0,0,0,1);
@ -1137,7 +1137,7 @@ void FramebufferManager::DecimateFBOs() {
fbo_unbind();
currentRenderVfb_ = 0;
int num = g_Config.iFrameSkip > 0 && g_Config.iFrameSkip != 9 ? g_Config.iFrameSkip : 3;
bool skipFrame = (gpuStats.numFrames % num == 0);
bool skipFrame = (gpuStats.numFlips % num == 0);
bool useFramebufferToMem = g_Config.iRenderingMode != FB_BUFFERED_MODE ? 1 : 0;
for (size_t i = 0; i < vfbs_.size(); ++i) {

View File

@ -111,7 +111,7 @@ void TextureCache::Decimate() {
lastBoundTexture = -1;
int killAge = lowMemoryMode_ ? TEXTURE_KILL_AGE_LOWMEM : TEXTURE_KILL_AGE;
for (TexCache::iterator iter = cache.begin(); iter != cache.end(); ) {
if (iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFrames) {
if (iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFlips) {
glDeleteTextures(1, &iter->second.texture);
cache.erase(iter++);
}
@ -119,7 +119,7 @@ void TextureCache::Decimate() {
++iter;
}
for (TexCache::iterator iter = secondCache.begin(); iter != secondCache.end(); ) {
if (lowMemoryMode_ || iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFrames) {
if (lowMemoryMode_ || iter->second.lastFrame + TEXTURE_KILL_AGE < gpuStats.numFlips) {
glDeleteTextures(1, &iter->second.texture);
secondCache.erase(iter++);
}
@ -949,17 +949,17 @@ bool SetDebugTexture() {
static int lastFrames = 0;
static int mostTextures = 1;
if (lastFrames != gpuStats.numFrames) {
if (lastFrames != gpuStats.numFlips) {
mostTextures = std::max(mostTextures, numTextures);
numTextures = 0;
lastFrames = gpuStats.numFrames;
lastFrames = gpuStats.numFlips;
}
static GLuint solidTexture = 0;
bool changed = false;
if (((gpuStats.numFrames / highlightFrames) % mostTextures) == numTextures) {
if (gpuStats.numFrames % highlightFrames == 0) {
if (((gpuStats.numFlips / highlightFrames) % mostTextures) == numTextures) {
if (gpuStats.numFlips % highlightFrames == 0) {
NOTICE_LOG(HLE, "Highlighting texture # %d / %d", numTextures, mostTextures);
}
static const u32 solidTextureData[] = {0x99AA99FF};
@ -1059,7 +1059,7 @@ void TextureCache::SetTexture() {
glBindTexture(GL_TEXTURE_2D, 0);
}
lastBoundTexture = -1;
entry->lastFrame = gpuStats.numFrames;
entry->lastFrame = gpuStats.numFlips;
return;
}
@ -1071,7 +1071,7 @@ void TextureCache::SetTexture() {
bool doDelete = true;
if (match) {
if (entry->lastFrame != gpuStats.numFrames) {
if (entry->lastFrame != gpuStats.numFlips) {
entry->numFrames++;
}
if (entry->framesUntilNextFullHash == 0) {
@ -1137,7 +1137,7 @@ void TextureCache::SetTexture() {
if (match) {
// TODO: Mark the entry reliable if it's been safe for long enough?
//got one!
entry->lastFrame = gpuStats.numFrames;
entry->lastFrame = gpuStats.numFlips;
if (entry->texture != lastBoundTexture) {
glBindTexture(GL_TEXTURE_2D, entry->texture);
lastBoundTexture = entry->texture;
@ -1183,7 +1183,7 @@ void TextureCache::SetTexture() {
entry->addr = texaddr;
entry->hash = texhash;
entry->format = format;
entry->lastFrame = gpuStats.numFrames;
entry->lastFrame = gpuStats.numFlips;
entry->framebuffer = 0;
entry->maxLevel = maxLevel;
entry->lodBias = 0.0f;

View File

@ -866,6 +866,7 @@ void TransformDrawEngine::SoftwareTransformAndDraw(
drawBuffer = 0; // so that the calls use offsets instead.
}
bool doTextureProjection = gstate.getUVGenMode() == 1;
glBindBuffer(GL_ARRAY_BUFFER, 0);
glVertexAttribPointer(program->a_position, 4, GL_FLOAT, GL_FALSE, vertexSize, drawBuffer);
if (program->a_texcoord != -1) glVertexAttribPointer(program->a_texcoord, doTextureProjection ? 3 : 2, GL_FLOAT, GL_FALSE, vertexSize, ((uint8_t*)drawBuffer) + 4 * 4);
if (program->a_color0 != -1) glVertexAttribPointer(program->a_color0, 4, GL_UNSIGNED_BYTE, GL_TRUE, vertexSize, ((uint8_t*)drawBuffer) + 7 * 4);
@ -1106,7 +1107,7 @@ void TransformDrawEngine::DecimateTrackedVertexArrays() {
return;
}
int threshold = gpuStats.numFrames - VAI_KILL_AGE;
int threshold = gpuStats.numFlips - VAI_KILL_AGE;
for (auto iter = vai_.begin(); iter != vai_.end(); ) {
if (iter->second->lastFrame < threshold) {
delete iter->second;
@ -1143,7 +1144,7 @@ void TransformDrawEngine::Flush() {
gpuStats.numTrackedVertexArrays = (int)vai_.size();
// TODO: This should not be done on every drawcall, we should collect vertex data
// This is not done on every drawcall, we should collect vertex data
// until critical state changes. That's when we draw (flush).
int prim = prevPrim_;
@ -1187,7 +1188,7 @@ void TransformDrawEngine::Flush() {
case VertexArrayInfo::VAI_HASHING:
{
vai->numDraws++;
if (vai->lastFrame != gpuStats.numFrames) {
if (vai->lastFrame != gpuStats.numFlips) {
vai->numFrames++;
}
if (vai->drawsUntilNextFullHash == 0) {
@ -1262,7 +1263,7 @@ void TransformDrawEngine::Flush() {
case VertexArrayInfo::VAI_RELIABLE:
{
vai->numDraws++;
if (vai->lastFrame != gpuStats.numFrames) {
if (vai->lastFrame != gpuStats.numFlips) {
vai->numFrames++;
}
gpuStats.numCachedDrawCalls++;
@ -1280,7 +1281,7 @@ void TransformDrawEngine::Flush() {
case VertexArrayInfo::VAI_UNRELIABLE:
{
vai->numDraws++;
if (vai->lastFrame != gpuStats.numFrames) {
if (vai->lastFrame != gpuStats.numFlips) {
vai->numFrames++;
}
DecodeVerts();
@ -1288,7 +1289,7 @@ void TransformDrawEngine::Flush() {
}
}
vai->lastFrame = gpuStats.numFrames;
vai->lastFrame = gpuStats.numFlips;
} else {
DecodeVerts();
rotateVBO:

View File

@ -59,7 +59,7 @@ public:
prim = -1;
numDraws = 0;
numFrames = 0;
lastFrame = gpuStats.numFrames;
lastFrame = gpuStats.numFlips;
numVerts = 0;
drawsUntilNextFullHash = 0;
}

View File

@ -17,39 +17,37 @@
#pragma once
#include "../Globals.h"
#include "GPUState.h"
#include "Globals.h"
#include "GPU/GPUState.h"
#include "Core/HLE/sceKernelThread.h"
#include <list>
#include <string>
class PointerWrap;
enum DisplayListStatus
{
/** The list has been completed */
enum DisplayListStatus {
// The list has been completed
PSP_GE_LIST_COMPLETED = 0,
/** The list is queued but not executed yet */
// The list is queued but not executed yet
PSP_GE_LIST_QUEUED = 1,
/** The list is currently being executed */
// The list is currently being executed
PSP_GE_LIST_DRAWING = 2,
/** The list was stopped because it encountered stall address */
// The list was stopped because it encountered stall address
PSP_GE_LIST_STALLING = 3,
/** The list is paused because of a signal or sceGeBreak */
// The list is paused because of a signal or sceGeBreak
PSP_GE_LIST_PAUSED = 4,
};
enum DisplayListState
{
/** No state assigned, the list is empty */
enum DisplayListState {
// No state assigned, the list is empty
PSP_GE_DL_STATE_NONE = 0,
/** The list has been queued */
// The list has been queued
PSP_GE_DL_STATE_QUEUED = 1,
/** The list is being executed */
// The list is being executed
PSP_GE_DL_STATE_RUNNING = 2,
/** The list was completed and will be removed */
// The list was completed and will be removed
PSP_GE_DL_STATE_COMPLETED = 3,
/** The list has been paused by a signal */
// The list has been paused by a signal
PSP_GE_DL_STATE_PAUSED = 4,
};

View File

@ -381,10 +381,11 @@ struct GPUStateCache
// TODO: Implement support for these.
struct GPUStatistics
{
void reset() {
void Reset() {
// Never add a vtable :)
memset(this, 0, sizeof(*this));
}
void resetFrame() {
void ResetFrame() {
numDrawCalls = 0;
numCachedDrawCalls = 0;
numVertsSubmitted = 0;
@ -418,7 +419,8 @@ struct GPUStatistics
int otherGPUCycles;
// Total statistics, updated by the GPU core in UpdateStats
int numFrames;
int numVBlanks;
int numFlips;
int numTextures;
int numVertexShaders;
int numFragmentShaders;

2
native

@ -1 +1 @@
Subproject commit bb82ffef4711054ba0181abdb519378eeff1e368
Subproject commit 0bff9046f68ede01b08f6859a2b49ef35a31d27f