Inconsistent use of pspDebugScreenSetOffset in the samples?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Smong
Posts: 82
Joined: Tue Sep 04, 2007 4:44 am

Inconsistent use of pspDebugScreenSetOffset in the samples?

Post by Smong »

While browsing the samples I have noticed an inconsistency regarding pspDebugScreenSetOffset, which as I understand sets which vram buffer pspDebugScreenPrintf's go to.

The problem I think exists is in some samples pspDebugScreenPrintf is being used on the wrong buffer half the time due to double buffering. The GU timing.c sample attempts to handle this by calling pspDebugScreenSetOffset, however it's also using an undocumented return value from sceDisplayWaitVblankStart as the pointer to the current draw buffer. speed.c also handles pspDebugScreenSetOffset. blend.c doesn't seem to handle it though.

So is using/not using pspDebugScreenSetOffset an issue? I think this inconsistency could just be an oversight by the sample authors. The samples serve their purpose and I am very grateful for them. I just want to make sure I'm doing the right thing in my programs.

I'm linking to code search results instead of the file since google uses some hash thing which could expire.
timing.c

Code: Select all

		pspDebugScreenSetOffset((int)frameBuffer);
		pspDebugScreenSetXY(0,0);
		pspDebugScreenPrintf("%s: %1d.%03d ms", modenames[mode], (end - start)/1000, (end - start)%1000);

		frameBuffer = (void*)sceDisplayWaitVblankStart();
		sceGuSwapBuffers();
Correctly calls pspDebugScreenSetOffset. Use of sceDisplayWaitVblankStart undocumented return value.

speed.c

Code: Select all

			pspDebugScreenSetOffset((int)fbp0);
			pspDebugScreenSetXY(0,0);
			pspDebugScreenPrintf("fps: %d.%03d (%dMB/s)",(int)curr_fps,(int)((curr_fps-(int)curr_fps) * 1000.0f),transfer_rate);
			pspDebugScreenSetXY(0,1);
			pspDebugScreenPrintf("%s %s %s %s",blit_method ? "optimized" : "normal", swizzle ? "swizzled" : "linear",vram_select ? "video ram" : "system ram", strip_widths[strip_width].name);
...
			fbp0 = sceGuSwapBuffers();
Buffers swapped and pointer to new draw buffer saved, pspDebugScreenSetOffset called.

blend.c

Code: Select all

		sceDisplayWaitVblankStart();
		sceGuSwapBuffers();
		pspDebugScreenSetXY(0,0);
		pspDebugScreenPrintf("%s",states[curr_state].name);
New draw buffer pointer not saved and pspDebugScreenSetOffset not called.


Also I haven't found any samples that use pspDebugScreenSetBase, I can only assume it is already initialised to the start of the memory mapped vram for you (0x04000000 according to google). I'm assuming pspDebugScreenSetOffset adds to this base since the VRAM pointers in the samples start at 0.

Edit: Amended speed.c parts.
Post Reply