Split texture load profiling into decode and load/replace. Make profiler work on Android.

This commit is contained in:
Henrik Rydgard 2015-05-15 17:14:54 +02:00
parent 6b1df631a6
commit 6f4cea860c
3 changed files with 16 additions and 9 deletions

View File

@ -180,7 +180,6 @@ void GPU_SwapBuffers() {
D3D9_SwapBuffers();
break;
}
PROFILE_END_FRAME();
}
#endif

View File

@ -1893,7 +1893,14 @@ TextureCache::TexCacheEntry::Status TextureCache::CheckAlpha(const u32 *pixelDat
}
void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replaceImages, int scaleFactor, GLenum dstFmt) {
PROFILE_THIS_SCOPE("loadtex");
int w = gstate.getTextureWidth(level);
int h = gstate.getTextureHeight(level);
bool useUnpack = false;
bool useBGRA;
u32 *pixelData;
{
PROFILE_THIS_SCOPE("decodetex");
// TODO: only do this once
u32 texByteAlign = 1;
@ -1905,13 +1912,9 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
return;
}
int w = gstate.getTextureWidth(level);
int h = gstate.getTextureHeight(level);
gpuStats.numTexturesDecoded++;
// Can restore these and remove the fixup at the end of DecodeTextureLevel on desktop GL and GLES 3.
bool useUnpack = false;
if ((g_Config.iTexScalingLevel == 1 && gl_extensions.EXT_unpack_subimage) && w != bufw) {
glPixelStorei(GL_UNPACK_ROW_LENGTH, bufw);
useUnpack = true;
@ -1919,9 +1922,9 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
glPixelStorei(GL_UNPACK_ALIGNMENT, texByteAlign);
bool useBGRA = UseBGRA8888() && dstFmt == GL_UNSIGNED_BYTE;
useBGRA = UseBGRA8888() && dstFmt == GL_UNSIGNED_BYTE;
u32 *pixelData = (u32 *)finalBuf;
pixelData = (u32 *)finalBuf;
if (scaleFactor > 1 && (entry.status & TexCacheEntry::STATUS_CHANGE_FREQUENT) == 0)
scaler.Scale(pixelData, dstFmt, w, h, scaleFactor);
@ -1931,6 +1934,7 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
} else {
entry.SetAlphaStatus(TexCacheEntry::STATUS_ALPHA_UNKNOWN);
}
}
GLuint components = dstFmt == GL_UNSIGNED_SHORT_5_6_5 ? GL_RGB : GL_RGBA;
@ -1940,8 +1944,10 @@ void TextureCache::LoadTextureLevel(TexCacheEntry &entry, int level, bool replac
}
if (replaceImages) {
PROFILE_THIS_SCOPE("repltex");
glTexSubImage2D(GL_TEXTURE_2D, level, 0, 0, w, h, components2, dstFmt, pixelData);
} else {
PROFILE_THIS_SCOPE("loadtex");
glTexImage2D(GL_TEXTURE_2D, level, components, w, h, 0, components2, dstFmt, pixelData);
if (!lowMemoryMode_) {
GLenum err = glGetError();

View File

@ -48,7 +48,6 @@
#include "file/zip_read.h"
#include "thread/thread.h"
#include "net/http_client.h"
#include "gfx_es2/gl_state.h" // should've been only for screenshot - but actually not, cleanup?
#include "gfx_es2/draw_text.h"
#include "gfx/gl_lost_manager.h"
#include "gfx/texture.h"
@ -57,6 +56,7 @@
#include "math/fast/fast_math.h"
#include "math/math_util.h"
#include "math/lin/matrix4x4.h"
#include "profiler/profiler.h"
#include "thin3d/thin3d.h"
#include "ui/ui.h"
#include "ui/screen.h"
@ -762,6 +762,8 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
}
void NativeUpdate(InputState &input) {
PROFILE_END_FRAME();
{
lock_guard lock(pendingMutex);
for (size_t i = 0; i < pendingMessages.size(); i++) {