PSP: zero-copy WindowSurface API for direct VRAM access
if all one needs is a raw framebuffer to the PSP's vram, instead of dealing with renderers and textures, that need to be copied hence and forth, this method allows one to create a window, set the pixel format using SDL_SetWindowDisplayMode() - preferably BGR565 for optimal speed (the other possible natively supported option is ABGR8888) - and then request SDL_GetWindowSurface(), which provides one with a surface with direct framebuffer access. note that the pixels pointer inside the surface will be switched after each call because of double-buffering. it's advisable to overwrite all pixels of the PSP visible area (480x272) to not encounter old data. after writing the pixels, a call to SDL_UpdateWindowSurface() sends the changes to the graphics chip. the result is a raw framerate of 250 fps with BGR565 mode, under optimal circumstances - i.e. nothing else is done than drawing, and the drawing loop is as simple as possible. that leaves about 12 ms per frame for other tasks and still allow a fluent 60 fps.
This commit is contained in:
1 parent
37c664a13d
commit
7b6695f4d4
4 files changed
+180
No files matched your search
@@ -36,6 +36,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <vram.h>
|
||||
#include "SDL_render_psp.h"
|
||||
|
||||
/* PSP renderer implementation, based on the PGE */
|
||||
|
||||
@@ -124,6 +125,24 @@ typedef struct
|
||||
float x, y, z;
|
||||
} VertTCV;
|
||||
|
||||
int SDL_PSP_RenderGetProp(SDL_Renderer *r, enum SDL_PSP_RenderProps which, void** out)
|
||||
{
|
||||
PSP_RenderData *rd;
|
||||
if (r == NULL) {
|
||||
return -1;
|
||||
}
|
||||
rd = r->driverdata;
|
||||
switch (which) {
|
||||
case SDL_PSP_RENDERPROPS_FRONTBUFFER:
|
||||
*out = rd->frontbuffer;
|
||||
return 0;
|
||||
case SDL_PSP_RENDERPROPS_BACKBUFFER:
|
||||
*out = rd->backbuffer;
|
||||
return 0;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#define PI 3.14159265358979f
|
||||
|
||||
#define radToDeg(x) ((x)*180.f / PI)
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
/* this header is meant to be included after the other related internal SDL
|
||||
headers. it's the interface between psp renderer and video driver code. */
|
||||
|
||||
enum SDL_PSP_RenderProps
|
||||
{
|
||||
SDL_PSP_RENDERPROPS_FRONTBUFFER,
|
||||
SDL_PSP_RENDERPROPS_BACKBUFFER,
|
||||
};
|
||||
|
||||
int SDL_PSP_RenderGetProp(SDL_Renderer *r, enum SDL_PSP_RenderProps which, void** out);
|
||||
|
||||
Reference in new issue
Block a user