mirror of https://github.com/encounter/SDL.git
Add more texture formats
This commit is contained in:
parent
0e9cd839d0
commit
c7cec2c792
|
@ -109,15 +109,41 @@ SDL_RenderDriver VITA_GXM_RenderDriver = {
|
|||
.info = {
|
||||
.name = "VITA gxm",
|
||||
.flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_TARGETTEXTURE,
|
||||
.num_texture_formats = 1,
|
||||
.num_texture_formats = 6,
|
||||
.texture_formats = {
|
||||
[0] = SDL_PIXELFORMAT_ABGR8888, // TODO: support more formats? ARGB8888 should be enough?
|
||||
[0] = SDL_PIXELFORMAT_ABGR8888,
|
||||
[1] = SDL_PIXELFORMAT_ARGB8888,
|
||||
[2] = SDL_PIXELFORMAT_RGB888,
|
||||
[3] = SDL_PIXELFORMAT_BGR888,
|
||||
[2] = SDL_PIXELFORMAT_RGB565,
|
||||
[3] = SDL_PIXELFORMAT_BGR565
|
||||
},
|
||||
.max_texture_width = 1024,
|
||||
.max_texture_height = 1024,
|
||||
}
|
||||
};
|
||||
|
||||
static int
|
||||
PixelFormatToVITAFMT(Uint32 format)
|
||||
{
|
||||
switch (format) {
|
||||
case SDL_PIXELFORMAT_ARGB8888:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB;
|
||||
case SDL_PIXELFORMAT_RGB888:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB;
|
||||
case SDL_PIXELFORMAT_BGR888:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
||||
case SDL_PIXELFORMAT_ABGR8888:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
||||
case SDL_PIXELFORMAT_RGB565:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U5U6U5_RGB;
|
||||
case SDL_PIXELFORMAT_BGR565:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U5U6U5_BGR;
|
||||
default:
|
||||
return SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ABGR;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
StartDrawing(SDL_Renderer *renderer)
|
||||
{
|
||||
|
@ -258,7 +284,7 @@ VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture)
|
|||
return SDL_OutOfMemory();
|
||||
}
|
||||
|
||||
vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, SCE_GXM_TEXTURE_FORMAT_A8B8G8R8, (texture->access == SDL_TEXTUREACCESS_TARGET));
|
||||
vita_texture->tex = create_gxm_texture(data, texture->w, texture->h, PixelFormatToVITAFMT(texture->format), (texture->access == SDL_TEXTUREACCESS_TARGET));
|
||||
|
||||
if (!vita_texture->tex) {
|
||||
SDL_free(vita_texture);
|
||||
|
|
|
@ -1046,12 +1046,9 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
|
|||
const int tex_size = ((w + 7) & ~ 7) * h * tex_format_to_bytespp(format);
|
||||
void *texture_data;
|
||||
|
||||
format = SCE_GXM_TEXTURE_FORMAT_A8B8G8R8;
|
||||
|
||||
if (!texture)
|
||||
return NULL;
|
||||
|
||||
|
||||
/* Allocate a GPU buffer for the texture */
|
||||
texture_data = mem_gpu_alloc(
|
||||
SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
|
||||
|
|
Loading…
Reference in New Issue