PSP: added option for render by callback and fixed up and cleaned up debug mechanism. This allows for about 4% speedup since we no longer need to wait for VSYNC in our main thread. I'll activate it as soon as I've tested it out properly.
svn-id: r49055
This commit is contained in:
parent
f4eacd6cc6
commit
8b59e45e6e
13 changed files with 134 additions and 71 deletions
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/display_client.h"
|
||||
#include "backends/platform/psp/default_display_client.h"
|
||||
#include "backends/platform/psp/cursor.h"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/display_client.h"
|
||||
#include "backends/platform/psp/default_display_client.h"
|
||||
|
||||
|
|
|
@ -24,10 +24,12 @@
|
|||
*/
|
||||
|
||||
#include <pspgu.h>
|
||||
#include <pspkerneltypes.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <psputils.h>
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/display_client.h"
|
||||
#include "backends/platform/psp/display_manager.h"
|
||||
#include "backends/platform/psp/memory.h"
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "common/singleton.h"
|
||||
#include "graphics/surface.h"
|
||||
#include "common/system.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/memory.h"
|
||||
|
||||
#define MAX_TEXTURE_SIZE 512
|
||||
|
|
|
@ -25,13 +25,17 @@
|
|||
|
||||
#include <pspgu.h>
|
||||
#include <pspdisplay.h>
|
||||
#include <pspthreadman.h>
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "backends/base-backend.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/display_client.h"
|
||||
#include "backends/platform/psp/default_display_client.h"
|
||||
#include "backends/platform/psp/cursor.h"
|
||||
#include "backends/platform/psp/pspkeyboard.h"
|
||||
|
||||
//#define USE_DISPLAY_CALLBACK // to use callback for finishing the render
|
||||
#include "backends/platform/psp/display_manager.h"
|
||||
|
||||
#define PSP_BUFFER_WIDTH (512)
|
||||
|
@ -56,9 +60,45 @@ const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
|
|||
{0, 0, 0}
|
||||
};
|
||||
|
||||
bool MasterGuRenderer::_renderFinished = true; // synchronizes the callback thread
|
||||
|
||||
// Class MasterGuRenderer ----------------------------------------------
|
||||
|
||||
void MasterGuRenderer::setupCallbackThread() {
|
||||
DEBUG_ENTER_FUNC();
|
||||
int thid = sceKernelCreateThread("displayCbThread", guCallbackThread, 0x11, 4*1024, THREAD_ATTR_USER, 0);
|
||||
|
||||
PSP_DEBUG_PRINT("Display CB thread id is %x\n", thid);
|
||||
|
||||
if (thid >= 0) {
|
||||
sceKernelStartThread(thid, 0, 0);
|
||||
} else
|
||||
PSP_ERROR("failed to create display callback thread\n");
|
||||
}
|
||||
|
||||
// thread that reacts to the callback
|
||||
int MasterGuRenderer::guCallbackThread(SceSize, void *) {
|
||||
DEBUG_ENTER_FUNC();
|
||||
|
||||
if (sceGuSetCallback(GU_CALLBACK_FINISH, guDisplayCallback) != 0) {
|
||||
PSP_ERROR("Warning: previous display callback found.\n");
|
||||
}
|
||||
PSP_DEBUG_PRINT("set callback. Going to sleep\n");
|
||||
|
||||
sceKernelSleepThreadCB(); // sleep until we get a callback
|
||||
return 0;
|
||||
}
|
||||
|
||||
// This callback is called when the render is finished. It swaps the buffers
|
||||
void MasterGuRenderer::guDisplayCallback(int) {
|
||||
if (_renderFinished == true)
|
||||
PSP_ERROR("callback thread found wrong value[true] in _renderFinished\n");
|
||||
|
||||
sceDisplayWaitVblankStart(); // wait for v-blank without eating main thread cycles
|
||||
sceGuSwapBuffers();
|
||||
_renderFinished = true; // Only this thread can set the variable to true
|
||||
}
|
||||
|
||||
void MasterGuRenderer::guInit() {
|
||||
DEBUG_ENTER_FUNC();
|
||||
|
||||
|
@ -110,6 +150,8 @@ void MasterGuRenderer::guProgramDisplayBufferSizes() {
|
|||
inline void MasterGuRenderer::guPreRender() {
|
||||
DEBUG_ENTER_FUNC();
|
||||
|
||||
_renderFinished = false; // set to synchronize with callback thread
|
||||
|
||||
#ifdef ENABLE_RENDER_MEASURE
|
||||
_lastRenderTime = g_system->getMillis();
|
||||
#endif /* ENABLE_RENDER_MEASURE */
|
||||
|
@ -132,6 +174,7 @@ inline void MasterGuRenderer::guPostRender() {
|
|||
DEBUG_ENTER_FUNC();
|
||||
|
||||
sceGuFinish();
|
||||
#ifndef USE_DISPLAY_CALLBACK
|
||||
sceGuSync(0, 0);
|
||||
|
||||
#ifdef ENABLE_RENDER_MEASURE
|
||||
|
@ -141,6 +184,8 @@ inline void MasterGuRenderer::guPostRender() {
|
|||
|
||||
sceDisplayWaitVblankStart();
|
||||
sceGuSwapBuffers();
|
||||
_renderFinished = true;
|
||||
#endif /* !USE_DISPLAY_CALLBACK */
|
||||
}
|
||||
|
||||
void MasterGuRenderer::guShutDown() {
|
||||
|
@ -164,11 +209,15 @@ void DisplayManager::init() {
|
|||
_overlay->init();
|
||||
_cursor->init();
|
||||
|
||||
|
||||
_masterGuRenderer.guInit(); // start up the renderer
|
||||
#ifdef USE_DISPLAY_CALLBACK
|
||||
_masterGuRenderer.setupCallbackThread();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void DisplayManager::setSizeAndPixelFormat(uint width, uint height, const Graphics::PixelFormat *format) {
|
||||
|
||||
DEBUG_ENTER_FUNC();
|
||||
PSP_DEBUG_PRINT("w[%u], h[%u], pformat[%p]\n", width, height, format);
|
||||
|
||||
|
@ -248,9 +297,15 @@ void DisplayManager::calculateScaleParams() {
|
|||
void DisplayManager::renderAll() {
|
||||
DEBUG_ENTER_FUNC();
|
||||
|
||||
if (!isTimeToUpdate()) {
|
||||
#ifdef USE_DISPLAY_CALLBACK
|
||||
if (!_masterGuRenderer.isRenderFinished()) {
|
||||
PSP_DEBUG_PRINT("Callback render not finished.\n");
|
||||
return;
|
||||
}
|
||||
#endif /* USE_DISPLAY_CALLBACK */
|
||||
|
||||
if (!isTimeToUpdate())
|
||||
return;
|
||||
|
||||
if (!_screen->isDirty() &&
|
||||
(!_overlay->isDirty()) &&
|
||||
|
|
|
@ -36,10 +36,15 @@ public:
|
|||
void guPreRender();
|
||||
void guPostRender();
|
||||
void guShutDown();
|
||||
bool isRenderFinished() { return _renderFinished; }
|
||||
void setupCallbackThread();
|
||||
private:
|
||||
static uint32 _displayList[];
|
||||
uint32 _lastRenderTime; // For measuring rendering
|
||||
void guProgramDisplayBufferSizes();
|
||||
static bool _renderFinished;
|
||||
static int guCallbackThread(SceSize, void *);
|
||||
static void guDisplayCallback(int);
|
||||
};
|
||||
|
||||
class Screen;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "backends/platform/psp/trace.h"
|
||||
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/input.h"
|
||||
|
||||
// Defines for working with PSP buttons
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "common/events.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/osys_psp.h"
|
||||
#include "backends/platform/psp/powerman.h"
|
||||
|
||||
|
|
|
@ -41,8 +41,9 @@
|
|||
#include "backends/platform/psp/powerman.h"
|
||||
|
||||
#include "backends/plugins/psp/psp-provider.h"
|
||||
#include "osys_psp.h"
|
||||
#include "./trace.h"
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/osys_psp.h"
|
||||
#include "backends/platform/psp/trace.h"
|
||||
|
||||
#ifdef ENABLE_PROFILING
|
||||
#include <pspprof.h>
|
||||
|
|
|
@ -29,18 +29,22 @@
|
|||
#define PSP_KB_SHELL_PATH "ms0:/psp/game4xx/scummvm-solid/" /* path to kbd.zip */
|
||||
#endif
|
||||
|
||||
//#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */
|
||||
//#define __PSP_DEBUG_PRINT__
|
||||
|
||||
#include "backends/platform/psp/trace.h"
|
||||
#include <malloc.h>
|
||||
#include "pspkernel.h"
|
||||
#include "png.h"
|
||||
#include <pspkernel.h>
|
||||
#include <png.h>
|
||||
|
||||
#include "backends/platform/psp/psppixelformat.h"
|
||||
#include "backends/platform/psp/pspkeyboard.h"
|
||||
#include "common/keyboard.h"
|
||||
#include "common/fs.h"
|
||||
#include "common/unzip.h"
|
||||
|
||||
//#define __PSP_DEBUG_FUNCS__ /* For debugging the stack */
|
||||
//#define __PSP_DEBUG_PRINT__
|
||||
|
||||
#include "backends/platform/psp/trace.h"
|
||||
|
||||
#define PSP_SCREEN_WIDTH 480
|
||||
#define PSP_SCREEN_HEIGHT 272
|
||||
#define K(x) ((short)(Common::KEYCODE_INVALID + (x)))
|
||||
|
|
|
@ -76,7 +76,7 @@ private:
|
|||
GuRenderer _renderer;
|
||||
|
||||
int loadPngImage(Common::SeekableReadStream *file, Buffer &buffer, Palette &palette);
|
||||
int getPngImageSize(Common::SeekableReadStream *, uint32 *png_width, uint32 *png_height, u32 *paletteSize);
|
||||
int getPngImageSize(Common::SeekableReadStream *, uint32 *png_width, uint32 *png_height, uint32 *paletteSize);
|
||||
uint32 convert_pow2(uint32 size);
|
||||
void increaseKeyboardLocationX(int amount); // Move keyboard onscreen
|
||||
void increaseKeyboardLocationY(int amount);
|
||||
|
|
|
@ -23,11 +23,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
#define TRACE_C
|
||||
|
||||
#include <pspkernel.h>
|
||||
#include <pspdebug.h>
|
||||
#include "backends/platform/psp/trace.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int psp_debug_indent = 0;
|
||||
|
||||
|
|
|
@ -24,47 +24,19 @@
|
|||
*/
|
||||
|
||||
|
||||
#ifndef TRACE_H
|
||||
#define TRACE_H
|
||||
// This section can only be included once
|
||||
#ifndef PSP_TRACE_H
|
||||
#define PSP_TRACE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <psptypes.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
// Use these defines for debugging
|
||||
|
||||
//#define __PSP_PRINT_TO_FILE__
|
||||
//#define __PSP_PRINT_TO_FILE_AND_SCREEN__
|
||||
//#define __PSP_DEBUG_FUNCS__ /* can put this locally too */
|
||||
//#define __PSP_DEBUG_PRINT__
|
||||
|
||||
void PSPDebugTrace(bool alsoToScreen, const char *format, ...);
|
||||
|
||||
#ifndef TRACE_C
|
||||
extern int psp_debug_indent;
|
||||
#endif
|
||||
|
||||
// From here on, we allow multiple definitions
|
||||
#undef __PSP_PRINT__
|
||||
#undef PSP_ERROR
|
||||
#undef __PSP_INDENT__
|
||||
#undef PSP_INFO_PRINT
|
||||
#undef PSP_INFO_PRINT_INDENT
|
||||
#undef PSP_DEBUG_PRINT
|
||||
#undef PSP_DEBUG_PRINT_FUNC
|
||||
#undef PSP_DEBUG_PRINT_SAMELN
|
||||
#undef PSP_DEBUG_DO
|
||||
#undef DEBUG_ENTER_FUNC
|
||||
#undef DEBUG_EXIT_FUNC
|
||||
#undef INLINE
|
||||
#include "common/str.h"
|
||||
|
||||
/* Choose to print to file/screen/both */
|
||||
#ifdef __PSP_PRINT_TO_FILE__
|
||||
#define __PSP_PRINT__(format,...) PSPDebugTrace(false, format, ## __VA_ARGS__)
|
||||
#define __PSP_PRINT__(format,...) PSPDebugTrace(false, format, ## __VA_ARGS__)
|
||||
#elif defined __PSP_PRINT_TO_FILE_AND_SCREEN__
|
||||
#define __PSP_PRINT__(format,...) PSPDebugTrace(true, format, ## __VA_ARGS__)
|
||||
#define __PSP_PRINT__(format,...) PSPDebugTrace(true, format, ## __VA_ARGS__)
|
||||
#else /* default - print to screen */
|
||||
#define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__)
|
||||
#define __PSP_PRINT__(format,...) fprintf(stderr, format, ## __VA_ARGS__)
|
||||
#endif /* PSP_PRINT_TO_FILE/SCREEN */
|
||||
|
||||
/* Error function */
|
||||
|
@ -80,28 +52,13 @@ extern int psp_debug_indent;
|
|||
#define PSP_INFO_PRINT_INDENT(format,...) { __PSP_INDENT__; \
|
||||
__PSP_PRINT__(format, ## __VA_ARGS__); }
|
||||
|
||||
#ifdef __PSP_DEBUG_PRINT__
|
||||
/* printf with indents */
|
||||
#define PSP_DEBUG_PRINT_SAMELN(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
|
||||
#define PSP_DEBUG_PRINT(format,...) { __PSP_INDENT__; \
|
||||
__PSP_PRINT__(format, ## __VA_ARGS__); }
|
||||
#define PSP_DEBUG_PRINT_FUNC(format,...) { __PSP_INDENT__; \
|
||||
__PSP_PRINT__("In %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__); }
|
||||
#define PSP_DEBUG_DO(x) (x)
|
||||
void PSPDebugTrace(bool alsoToScreen, const char *format, ...);
|
||||
|
||||
#else /* no debug print */
|
||||
#define PSP_DEBUG_PRINT_SAMELN(format,...)
|
||||
#define PSP_DEBUG_PRINT(format,...)
|
||||
#define PSP_DEBUG_PRINT_FUNC(format,...)
|
||||
#define PSP_DEBUG_DO(x)
|
||||
#endif /* __PSP_DEBUG_PRINT__ */
|
||||
|
||||
/* Debugging function calls */
|
||||
#ifdef __PSP_DEBUG_FUNCS__
|
||||
extern int psp_debug_indent;
|
||||
|
||||
// We use this class to print out function calls on the stack in an easy way.
|
||||
//
|
||||
#include "common/str.h"
|
||||
|
||||
class PSPStackDebugFuncs {
|
||||
Common::String _name;
|
||||
|
||||
|
@ -119,7 +76,45 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
#endif /* PSP_TRACE_H */
|
||||
|
||||
|
||||
|
||||
|
||||
// From here on, we allow multiple redefinitions
|
||||
|
||||
// Use these defines for debugging
|
||||
|
||||
//#define __PSP_PRINT_TO_FILE__
|
||||
//#define __PSP_PRINT_TO_FILE_AND_SCREEN__
|
||||
//#define __PSP_DEBUG_FUNCS__ /* can put this locally too */
|
||||
//#define __PSP_DEBUG_PRINT__
|
||||
|
||||
#undef PSP_DEBUG_PRINT
|
||||
#undef PSP_DEBUG_PRINT_FUNC
|
||||
#undef PSP_DEBUG_PRINT_SAMELN
|
||||
#undef PSP_DEBUG_DO
|
||||
#undef DEBUG_ENTER_FUNC
|
||||
#undef DEBUG_EXIT_FUNC
|
||||
|
||||
#ifdef __PSP_DEBUG_PRINT__
|
||||
/* printf with indents */
|
||||
#define PSP_DEBUG_PRINT_SAMELN(format,...) __PSP_PRINT__(format, ## __VA_ARGS__)
|
||||
#define PSP_DEBUG_PRINT(format,...) PSP_INFO_PRINT_INDENT(format, ## __VA_ARGS__)
|
||||
#define PSP_DEBUG_PRINT_FUNC(format,...) { __PSP_INDENT__; \
|
||||
__PSP_PRINT__("In %s: " format, __PRETTY_FUNCTION__, ## __VA_ARGS__); }
|
||||
#define PSP_DEBUG_DO(x) (x)
|
||||
|
||||
#else /* no debug print */
|
||||
#define PSP_DEBUG_PRINT_SAMELN(format,...)
|
||||
#define PSP_DEBUG_PRINT(format,...)
|
||||
#define PSP_DEBUG_PRINT_FUNC(format,...)
|
||||
#define PSP_DEBUG_DO(x)
|
||||
#endif /* __PSP_DEBUG_PRINT__ */
|
||||
|
||||
/* We don't need anything but this line at the beginning of each function to debug function calls */
|
||||
/* Debugging function calls */
|
||||
#ifdef __PSP_DEBUG_FUNCS__
|
||||
#define DEBUG_ENTER_FUNC() volatile PSPStackDebugFuncs __foo(__PRETTY_FUNCTION__)
|
||||
#else /* Don't debug function calls */
|
||||
#define DEBUG_ENTER_FUNC()
|
||||
|
@ -130,5 +125,3 @@ public:
|
|||
#undef __PSP_PRINT_TO_FILE_AND_SCREEN__
|
||||
#undef __PSP_DEBUG_FUNCS__
|
||||
#undef __PSP_DEBUG_PRINT__
|
||||
|
||||
#endif /* TRACE_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue