Commit e74bc6f8 authored by Mike Gorchak's avatar Mike Gorchak

Continue working on QNX GF and Photon support.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%403643
parent e51e3cfd
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
#endif /* SDL_VIDEO_OPENGL_ES */ #endif /* SDL_VIDEO_OPENGL_ES */
/* Low level device graphics driver names, which they are reporting */ /* Low level device graphics driver names, which they are reporting */
Photon_DeviceCaps photon_devicename[] = { static const Photon_DeviceCaps photon_devicename[] = {
/* ATI Rage 128 graphics driver (devg-ati_rage128) */ /* ATI Rage 128 graphics driver (devg-ati_rage128) */
{"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D}
, ,
...@@ -384,19 +384,47 @@ photon_videoinit(_THIS) ...@@ -384,19 +384,47 @@ photon_videoinit(_THIS)
/* Query photon about graphics hardware caps and current video mode */ /* Query photon about graphics hardware caps and current video mode */
status = PgGetGraphicsHWCaps(&hwcaps); status = PgGetGraphicsHWCaps(&hwcaps);
if (status != 0) { if (status != 0) {
SDL_SetError("Photon: Can't get graphics capabilities"); PhRect_t extent;
SDL_free(didata->cursor); PdOffscreenContext_t* curctx;
SDL_free(didata);
return -1;
}
/* Get current video mode details */ /* If error happens, this also could mean, that photon is working */
status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo); /* under custom (not listed by photon) video mode */
if (status != 0) { status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent);
SDL_SetError("Photon: Can't get current video mode information"); if (status != 0) {
SDL_free(didata->cursor); SDL_SetError("Photon: Can't get graphics driver region");
SDL_free(didata); SDL_free(didata->cursor);
return -1; SDL_free(didata);
return -1;
}
modeinfo.width=extent.lr.x+1;
modeinfo.height=extent.lr.y+1;
/* Hardcode 60Hz, as the base refresh rate frequency */
hwcaps.current_rrate=60;
/* Clear current video driver name, no way to get it somehow */
hwcaps.chip_name[0]=0x00;
/* Create offscreen context from video memory, which is currently */
/* displayed on the screen */
curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
if (curctx==NULL)
{
SDL_SetError("Photon: Can't get display area capabilities");
SDL_free(didata->cursor);
SDL_free(didata);
return -1;
}
/* Retrieve current bpp */
modeinfo.type=curctx->format;
PhDCRelease(curctx);
} else {
/* Get current video mode details */
status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo);
if (status != 0) {
SDL_SetError("Photon: Can't get current video mode information");
SDL_free(didata->cursor);
SDL_free(didata);
return -1;
}
} }
/* Setup current desktop mode for SDL */ /* Setup current desktop mode for SDL */
...@@ -527,6 +555,27 @@ photon_getdisplaymodes(_THIS) ...@@ -527,6 +555,27 @@ photon_getdisplaymodes(_THIS)
mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); mode.format = photon_image_to_sdl_pixelformat(modeinfo.type);
mode.driverdata = NULL; mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode); SDL_AddDisplayMode(_this->current_display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.type == Pg_IMAGE_DIRECT_8888) {
mode.w = modeinfo.width;
mode.h = modeinfo.height;
mode.refresh_rate = modeinfo.refresh_rates[jt];
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
if (modeinfo.type == Pg_IMAGE_DIRECT_1555) {
mode.w = modeinfo.width;
mode.h = modeinfo.height;
mode.refresh_rate = modeinfo.refresh_rates[jt];
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
jt++; jt++;
} else { } else {
break; break;
...@@ -1453,7 +1502,7 @@ photon_gl_createcontext(_THIS, SDL_Window * window) ...@@ -1453,7 +1502,7 @@ photon_gl_createcontext(_THIS, SDL_Window * window)
if (configs == 0) { if (configs == 0) {
int32_t it; int32_t it;
int32_t jt; int32_t jt;
GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
for (it = 0; it < 4; it++) { for (it = 0; it < 4; it++) {
for (jt = 16; jt >= 0; jt--) { for (jt = 16; jt >= 0; jt--) {
......
...@@ -72,6 +72,11 @@ photon_sdl_to_bits_pixelformat(uint32_t pixelfmt) ...@@ -72,6 +72,11 @@ photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
return 15; return 15;
} }
break; break;
case SDL_PIXELFORMAT_RGB555:
{
return 15;
}
break;
case SDL_PIXELFORMAT_ABGR1555: case SDL_PIXELFORMAT_ABGR1555:
{ {
return 15; return 15;
...@@ -82,11 +87,16 @@ photon_sdl_to_bits_pixelformat(uint32_t pixelfmt) ...@@ -82,11 +87,16 @@ photon_sdl_to_bits_pixelformat(uint32_t pixelfmt)
return 16; return 16;
} }
break; break;
case SDL_PIXELFORMAT_RGB888: case SDL_PIXELFORMAT_RGB24:
{ {
return 24; return 24;
} }
break; break;
case SDL_PIXELFORMAT_RGB888:
{
return 32;
}
break;
case SDL_PIXELFORMAT_BGRA8888: case SDL_PIXELFORMAT_BGRA8888:
{ {
return 32; return 32;
...@@ -133,12 +143,12 @@ photon_image_to_sdl_pixelformat(uint32_t pixelfmt) ...@@ -133,12 +143,12 @@ photon_image_to_sdl_pixelformat(uint32_t pixelfmt)
break; break;
case Pg_IMAGE_DIRECT_8888: case Pg_IMAGE_DIRECT_8888:
{ {
return SDL_PIXELFORMAT_BGRA8888; return SDL_PIXELFORMAT_ARGB8888;
} }
break; break;
case Pg_IMAGE_DIRECT_888: case Pg_IMAGE_DIRECT_888:
{ {
return SDL_PIXELFORMAT_RGB888; return SDL_PIXELFORMAT_RGB24;
} }
break; break;
case Pg_IMAGE_DIRECT_565: case Pg_IMAGE_DIRECT_565:
...@@ -170,12 +180,12 @@ photon_sdl_to_image_pixelformat(uint32_t pixelfmt) ...@@ -170,12 +180,12 @@ photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
return Pg_IMAGE_PALETTE_BYTE; return Pg_IMAGE_PALETTE_BYTE;
} }
break; break;
case SDL_PIXELFORMAT_BGRA8888: case SDL_PIXELFORMAT_ARGB8888:
{ {
return Pg_IMAGE_DIRECT_8888; return Pg_IMAGE_DIRECT_8888;
} }
break; break;
case SDL_PIXELFORMAT_RGB888: case SDL_PIXELFORMAT_RGB24:
{ {
return Pg_IMAGE_DIRECT_888; return Pg_IMAGE_DIRECT_888;
} }
...@@ -190,6 +200,11 @@ photon_sdl_to_image_pixelformat(uint32_t pixelfmt) ...@@ -190,6 +200,11 @@ photon_sdl_to_image_pixelformat(uint32_t pixelfmt)
return Pg_IMAGE_DIRECT_1555; return Pg_IMAGE_DIRECT_1555;
} }
break; break;
case SDL_PIXELFORMAT_RGB555:
{
return Pg_IMAGE_DIRECT_555;
}
break;
} }
return 0; return 0;
......
...@@ -41,8 +41,9 @@ qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt) ...@@ -41,8 +41,9 @@ qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
return GF_FORMAT_PACK_ARGB1555; return GF_FORMAT_PACK_ARGB1555;
} }
break; break;
case SDL_PIXELFORMAT_ABGR1555: case SDL_PIXELFORMAT_RGB555:
{ {
/* RGB555 is the same as ARGB1555, but alpha is ignored */
return GF_FORMAT_PACK_ARGB1555; return GF_FORMAT_PACK_ARGB1555;
} }
break; break;
...@@ -51,18 +52,33 @@ qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt) ...@@ -51,18 +52,33 @@ qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt)
return GF_FORMAT_PACK_RGB565; return GF_FORMAT_PACK_RGB565;
} }
break; break;
case SDL_PIXELFORMAT_RGB888: case SDL_PIXELFORMAT_BGR565:
{ {
return GF_FORMAT_PKBE_RGB565;
}
break;
case SDL_PIXELFORMAT_RGB24:
{
/* GF has wrong components order */
return GF_FORMAT_BGR888; return GF_FORMAT_BGR888;
} }
break; break;
case SDL_PIXELFORMAT_BGRA8888: case SDL_PIXELFORMAT_RGB888:
{ {
/* The same format as ARGB8888, but with alpha ignored */
/* and GF has wrong components order */
return GF_FORMAT_BGRA8888; return GF_FORMAT_BGRA8888;
} }
break; break;
case SDL_PIXELFORMAT_ARGB8888: case SDL_PIXELFORMAT_ARGB8888:
{ {
/* GF has wrong components order */
return GF_FORMAT_BGRA8888;
}
break;
case SDL_PIXELFORMAT_BGRA8888:
{
/* GF has wrong components order */
return GF_FORMAT_ARGB8888; return GF_FORMAT_ARGB8888;
} }
break; break;
...@@ -110,14 +126,9 @@ qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt) ...@@ -110,14 +126,9 @@ qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
return SDL_PIXELFORMAT_ARGB1555; return SDL_PIXELFORMAT_ARGB1555;
} }
break; break;
case GF_FORMAT_PKBE_ARGB1555:
{
return SDL_PIXELFORMAT_ABGR1555;
}
break;
case GF_FORMAT_PKBE_RGB565: case GF_FORMAT_PKBE_RGB565:
{ {
return SDL_PIXELFORMAT_RGB565; return SDL_PIXELFORMAT_BGR565;
} }
break; break;
case GF_FORMAT_PKLE_RGB565: case GF_FORMAT_PKLE_RGB565:
...@@ -132,20 +143,22 @@ qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt) ...@@ -132,20 +143,22 @@ qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt)
break; break;
case GF_FORMAT_BGR888: case GF_FORMAT_BGR888:
{ {
return SDL_PIXELFORMAT_RGB888; /* GF has wrong components order */
return SDL_PIXELFORMAT_RGB24;
} }
break; break;
case GF_FORMAT_BGRA8888: case GF_FORMAT_BGRA8888:
{ {
return SDL_PIXELFORMAT_BGRA8888; /* GF has wrong components order */
return SDL_PIXELFORMAT_ARGB8888;
} }
break; break;
case GF_FORMAT_ARGB8888: case GF_FORMAT_ARGB8888:
{ {
return SDL_PIXELFORMAT_ARGB8888; /* GF has wrong components order */
return SDL_PIXELFORMAT_BGRA8888;
} }
break; break;
case GF_FORMAT_PLANAR_YUV_YV12: case GF_FORMAT_PLANAR_YUV_YV12:
{ {
return SDL_PIXELFORMAT_YV12; return SDL_PIXELFORMAT_YV12;
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
/* but some drivers are not. Later we can distinguish one driver from another */ /* but some drivers are not. Later we can distinguish one driver from another */
/* Feel free to add any new custom graphics mode */ /* Feel free to add any new custom graphics mode */
/******************************************************************************/ /******************************************************************************/
static SDL_DisplayMode generic_mode[] = { static const SDL_DisplayMode generic_mode[] = {
{0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */ {0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */
{0, 320, 200, 85, NULL}, {0, 320, 200, 85, NULL},
{0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */ {0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */
...@@ -100,7 +100,7 @@ static SDL_DisplayMode generic_mode[] = { ...@@ -100,7 +100,7 @@ static SDL_DisplayMode generic_mode[] = {
}; };
/* Low level device graphics driver names, which they are reporting */ /* Low level device graphics driver names, which they are reporting */
GF_DeviceCaps gf_devicename[] = { static const GF_DeviceCaps gf_devicename[] = {
/* ATI Rage 128 graphics driver (devg-ati_rage128) */ /* ATI Rage 128 graphics driver (devg-ati_rage128) */
{"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION |
SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY},
...@@ -644,6 +644,25 @@ qnxgf_getdisplaymodes(_THIS) ...@@ -644,6 +644,25 @@ qnxgf_getdisplaymodes(_THIS)
mode.driverdata = NULL; mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode); SDL_AddDisplayMode(_this->current_display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
mode.w = generic_mode[jt].w;
mode.h = generic_mode[jt].h;
mode.refresh_rate = generic_mode[jt].refresh_rate;
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
mode.w = generic_mode[jt].w;
mode.h = generic_mode[jt].h;
mode.refresh_rate = generic_mode[jt].refresh_rate;
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
jt++; jt++;
} while (1); } while (1);
} else { } else {
...@@ -660,6 +679,26 @@ qnxgf_getdisplaymodes(_THIS) ...@@ -660,6 +679,26 @@ qnxgf_getdisplaymodes(_THIS)
primary_format); primary_format);
mode.driverdata = NULL; mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode); SDL_AddDisplayMode(_this->current_display, &mode);
/* If mode is RGBA8888, add the same mode as RGBx888 */
if (modeinfo.primary_format==GF_FORMAT_BGRA8888) {
mode.w = modeinfo.xres;
mode.h = modeinfo.yres;
mode.refresh_rate = modeinfo.refresh[jt];
mode.format = SDL_PIXELFORMAT_RGB888;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
/* If mode is RGBA1555, add the same mode as RGBx555 */
if (modeinfo.primary_format==GF_FORMAT_PACK_ARGB1555) {
mode.w = modeinfo.xres;
mode.h = modeinfo.yres;
mode.refresh_rate = modeinfo.refresh[jt];
mode.format = SDL_PIXELFORMAT_RGB555;
mode.driverdata = NULL;
SDL_AddDisplayMode(_this->current_display, &mode);
}
jt++; jt++;
} else { } else {
break; break;
...@@ -823,7 +862,7 @@ qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode) ...@@ -823,7 +862,7 @@ qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode)
/* Mark main display layer is attached */ /* Mark main display layer is attached */
didata->layer_attached = SDL_TRUE; didata->layer_attached = SDL_TRUE;
/* Set layer source and destination viewport */ /* Set layer source and destination viewports */
gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1);
...@@ -1464,7 +1503,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window) ...@@ -1464,7 +1503,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window)
if (configs == 0) { if (configs == 0) {
int32_t it; int32_t it;
int32_t jt; int32_t jt;
GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE };
for (it = 0; it < 4; it++) { for (it = 0; it < 4; it++) {
for (jt = 16; jt >= 0; jt--) { for (jt = 16; jt >= 0; jt--) {
...@@ -1520,7 +1559,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window) ...@@ -1520,7 +1559,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window)
SDL_VIDEO_GF_OPENGLES_CONFS, &configs); SDL_VIDEO_GF_OPENGLES_CONFS, &configs);
if (status != EGL_TRUE) { if (status != EGL_TRUE) {
SDL_SetError SDL_SetError
("Photon: Can't find closest configuration for OpenGL ES"); ("GF: Can't find closest configuration for OpenGL ES");
return NULL; return NULL;
} }
if (configs != 0) { if (configs != 0) {
...@@ -1535,7 +1574,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window) ...@@ -1535,7 +1574,7 @@ qnxgf_gl_createcontext(_THIS, SDL_Window * window)
/* No available configs */ /* No available configs */
if (configs == 0) { if (configs == 0) {
SDL_SetError SDL_SetError
("Photon: Can't find any configuration for OpenGL ES"); ("GF: Can't find any configuration for OpenGL ES");
return NULL; return NULL;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment