early-access version 2325
This commit is contained in:
76
externals/SDL/src/render/psp/SDL_render_psp.c
vendored
76
externals/SDL/src/render/psp/SDL_render_psp.c
vendored
@@ -165,11 +165,10 @@ void Swap(float *a, float *b)
|
||||
static int
|
||||
TextureNextPow2(unsigned int w)
|
||||
{
|
||||
unsigned int n = 2;
|
||||
if(w == 0)
|
||||
return 0;
|
||||
|
||||
unsigned int n = 2;
|
||||
|
||||
while(w > n)
|
||||
n <<= 1;
|
||||
|
||||
@@ -209,30 +208,32 @@ StartDrawing(SDL_Renderer * renderer)
|
||||
int
|
||||
TextureSwizzle(PSP_TextureData *psp_texture)
|
||||
{
|
||||
int bytewidth, height;
|
||||
int rowblocks, rowblocksadd;
|
||||
int i, j;
|
||||
unsigned int blockaddress = 0;
|
||||
unsigned int *src = NULL;
|
||||
unsigned char *data = NULL;
|
||||
|
||||
if(psp_texture->swizzled)
|
||||
return 1;
|
||||
|
||||
int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
int height = psp_texture->size / bytewidth;
|
||||
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
height = psp_texture->size / bytewidth;
|
||||
|
||||
int rowblocks = (bytewidth>>4);
|
||||
int rowblocksadd = (rowblocks-1)<<7;
|
||||
unsigned int blockaddress = 0;
|
||||
unsigned int *src = (unsigned int*) psp_texture->data;
|
||||
rowblocks = (bytewidth>>4);
|
||||
rowblocksadd = (rowblocks-1)<<7;
|
||||
|
||||
src = (unsigned int*) psp_texture->data;
|
||||
|
||||
unsigned char *data = NULL;
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
|
||||
int j;
|
||||
|
||||
for(j = 0; j < height; j++, blockaddress += 16)
|
||||
{
|
||||
unsigned int *block;
|
||||
|
||||
block = (unsigned int*)&data[blockaddress];
|
||||
|
||||
int i;
|
||||
|
||||
for(i = 0; i < rowblocks; i++)
|
||||
{
|
||||
*block++ = *src++;
|
||||
@@ -254,23 +255,28 @@ TextureSwizzle(PSP_TextureData *psp_texture)
|
||||
}
|
||||
int TextureUnswizzle(PSP_TextureData *psp_texture)
|
||||
{
|
||||
int bytewidth, height;
|
||||
int widthblocks, heightblocks;
|
||||
int dstpitch, dstrow;
|
||||
int blockx, blocky;
|
||||
int j;
|
||||
unsigned int *src = NULL;
|
||||
unsigned char *data = NULL;
|
||||
unsigned char *ydst = NULL;
|
||||
|
||||
if(!psp_texture->swizzled)
|
||||
return 1;
|
||||
|
||||
int blockx, blocky;
|
||||
bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
height = psp_texture->size / bytewidth;
|
||||
|
||||
int bytewidth = psp_texture->textureWidth*(psp_texture->bits>>3);
|
||||
int height = psp_texture->size / bytewidth;
|
||||
widthblocks = bytewidth/16;
|
||||
heightblocks = height/8;
|
||||
|
||||
int widthblocks = bytewidth/16;
|
||||
int heightblocks = height/8;
|
||||
dstpitch = (bytewidth - 16)/4;
|
||||
dstrow = bytewidth * 8;
|
||||
|
||||
int dstpitch = (bytewidth - 16)/4;
|
||||
int dstrow = bytewidth * 8;
|
||||
|
||||
unsigned int *src = (unsigned int*) psp_texture->data;
|
||||
|
||||
unsigned char *data = NULL;
|
||||
src = (unsigned int*) psp_texture->data;
|
||||
|
||||
data = SDL_malloc(psp_texture->size);
|
||||
|
||||
@@ -279,9 +285,7 @@ int TextureUnswizzle(PSP_TextureData *psp_texture)
|
||||
|
||||
sceKernelDcacheWritebackAll();
|
||||
|
||||
int j;
|
||||
|
||||
unsigned char *ydst = (unsigned char *)data;
|
||||
ydst = (unsigned char *)data;
|
||||
|
||||
for(blocky = 0; blocky < heightblocks; ++blocky)
|
||||
{
|
||||
@@ -655,7 +659,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
|
||||
cmd->data.draw.count = count;
|
||||
|
||||
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * sizeof (VertTV), 4, &cmd->data.draw.first);
|
||||
verts = (VertTV *) SDL_AllocateRenderVertices(renderer, count * 2 * sizeof (VertTV), 4, &cmd->data.draw.first);
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
@@ -673,6 +677,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
verts->x = curX;
|
||||
verts->y = y;
|
||||
verts->z = 0;
|
||||
verts++;
|
||||
|
||||
curU += sourceWidth;
|
||||
curX += polyWidth;
|
||||
@@ -682,6 +687,7 @@ PSP_QueueCopy(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * tex
|
||||
verts->x = curX;
|
||||
verts->y = (y + height);
|
||||
verts->z = 0;
|
||||
verts++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -701,6 +707,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||
const float width = dstrect->w - centerx;
|
||||
const float height = dstrect->h - centery;
|
||||
float s, c;
|
||||
float cw, sw, ch, sh;
|
||||
|
||||
float u0 = srcrect->x;
|
||||
float v0 = srcrect->y;
|
||||
@@ -708,6 +715,7 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||
float v1 = srcrect->y + srcrect->h;
|
||||
|
||||
|
||||
|
||||
if (!verts) {
|
||||
return -1;
|
||||
}
|
||||
@@ -716,10 +724,10 @@ PSP_QueueCopyEx(SDL_Renderer * renderer, SDL_RenderCommand *cmd, SDL_Texture * t
|
||||
|
||||
MathSincos(degToRad(angle), &s, &c);
|
||||
|
||||
const float cw = c * width;
|
||||
const float sw = s * width;
|
||||
const float ch = c * height;
|
||||
const float sh = s * height;
|
||||
cw = c * width;
|
||||
sw = s * width;
|
||||
ch = c * height;
|
||||
sh = s * height;
|
||||
|
||||
if (flip & SDL_FLIP_VERTICAL) {
|
||||
Swap(&v0, &v1);
|
||||
@@ -799,7 +807,7 @@ static int
|
||||
PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *vertices, size_t vertsize)
|
||||
{
|
||||
PSP_RenderData *data = (PSP_RenderData *) renderer->driverdata;
|
||||
|
||||
Uint8 *gpumem = NULL;
|
||||
StartDrawing(renderer);
|
||||
|
||||
/* note that before the renderer interface change, this would do extrememly small
|
||||
@@ -808,7 +816,7 @@ PSP_RunCommandQueue(SDL_Renderer * renderer, SDL_RenderCommand *cmd, void *verti
|
||||
I don't know what the limits on PSP hardware are. It might be useful to have
|
||||
rendering backends report a reasonable maximum, so the higher level can flush
|
||||
if we appear to be exceeding that. */
|
||||
Uint8 *gpumem = (Uint8 *) sceGuGetMemory(vertsize);
|
||||
gpumem = (Uint8 *) sceGuGetMemory(vertsize);
|
||||
if (!gpumem) {
|
||||
return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int) vertsize);
|
||||
}
|
||||
|
Reference in New Issue
Block a user