Add more texture formats
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
index d3c2f9d..d861c11 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -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);
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index 411c70c..f410f08 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -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,