Support GL1 on osx-ppc (#13569)

* Fix handling of big-endianness in gl1

* Enable gl1 on osx-ppc

* Force gl1 on apple if gfx supports only gl1

* Backport gl2 apple workaround to gl1

* Fix big-endianness handling in widgets
This commit is contained in:
Vladimir Serbinenko 2022-01-30 09:30:39 +01:00 committed by GitHub
parent cce04bab70
commit 17ccfe4004
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 4 deletions

View file

@ -278,6 +278,15 @@ static void *gl1_gfx_init(const video_info_t *video,
gl1->ctx_driver->get_video_size(gl1->ctx_data,
&mode_width, &mode_height);
#if defined(__APPLE__) && !defined(IOS)
/* This is a hack for now to work around a very annoying
* issue that currently eludes us. */
if ( !gl1->ctx_driver->set_video_mode
|| !gl1->ctx_driver->set_video_mode(gl1->ctx_data,
win_width, win_height, video->fullscreen))
goto error;
#endif
full_x = mode_width;
full_y = mode_height;
mode_width = 0;
@ -560,8 +569,17 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
uint8_t *frame_rgba = NULL;
/* FIXME: For now, everything is uploaded as BGRA8888, I could not get 444 or 555 to work, and there is no 565 support in GL 1.1 either. */
GLint internalFormat = GL_RGB8;
GLenum format = gl1->supports_bgra ? GL_BGRA_EXT : GL_RGBA;
#ifdef MSB_FIRST
bool supports_native = gl1->supports_bgra;
GLenum format = supports_native ? GL_BGRA_EXT : GL_RGBA;
GLenum type = supports_native ? GL_UNSIGNED_INT_8_8_8_8_REV : GL_UNSIGNED_BYTE;
#elif defined(LSB_FIRST)
bool supports_native = gl1->supports_bgra;
GLenum format = supports_native ? GL_BGRA_EXT : GL_RGBA;
GLenum type = GL_UNSIGNED_BYTE;
#else
#error Broken endianness definition
#endif
float vertices[] = {
-1.0f, -1.0f, 0.0f,
@ -606,7 +624,8 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
glBindTexture(GL_TEXTURE_2D, tex);
frame = (uint8_t*)frame_to_copy;
if (!gl1->supports_bgra)
if (!supports_native)
{
frame_rgba = (uint8_t*)malloc(pot_width * pot_height * 4);
if (frame_rgba)
@ -617,10 +636,17 @@ static void draw_tex(gl1_t *gl1, int pot_width, int pot_height, int width, int h
for (x = 0; x < pot_width; x++)
{
int index = (y * pot_width + x) * 4;
#ifdef MSB_FIRST
frame_rgba[index + 2] = frame[index + 3];
frame_rgba[index + 1] = frame[index + 2];
frame_rgba[index + 0] = frame[index + 1];
frame_rgba[index + 3] = frame[index + 0];
#else
frame_rgba[index + 2] = frame[index + 0];
frame_rgba[index + 1] = frame[index + 1];
frame_rgba[index + 0] = frame[index + 2];
frame_rgba[index + 3] = frame[index + 3];
#endif
}
}
frame = frame_rgba;
@ -924,7 +950,12 @@ static bool gl1_gfx_frame(void *data, const void *frame,
/* Screenshots. */
if (gl1->readback_buffer_screenshot)
gl1_readback(gl1,
4, GL_RGBA, GL_UNSIGNED_BYTE,
4, GL_RGBA,
#ifdef MSB_FIRST
GL_UNSIGNED_INT_8_8_8_8_REV,
#else
GL_UNSIGNED_BYTE,
#endif
gl1->readback_buffer_screenshot);
@ -1312,7 +1343,12 @@ static void gl1_load_texture_data(
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL1_INTERNAL_FORMAT32,
width, height, 0,
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL1_TEXTURE_TYPE32,
(rgb32) ? RARCH_GL1_FORMAT32 : GL_UNSIGNED_BYTE, frame);
#ifdef MSB_FIRST
GL_UNSIGNED_INT_8_8_8_8_REV,
#else
(rgb32) ? RARCH_GL1_FORMAT32 : GL_UNSIGNED_BYTE,
#endif
frame);
}
static void video_texture_load_gl1(

View file

@ -3735,6 +3735,10 @@ static void *gl2_init(const video_info_t *video,
#else
video_driver_force_fallback("gdi");
#endif
#endif
#if defined(__APPLE__) && defined(__ppc__)
if (gl->version_major == 1)
video_driver_force_fallback("gl1");
#endif
hwr = video_driver_get_hw_context();

View file

@ -321,6 +321,7 @@
"-DHAVE_GFX_WIDGETS",
"-DOSX",
"-DHAVE_OPENGL",
"-DHAVE_OPENGL1",
"-DHAVE_CC_RESAMPLER",
"-DHAVE_GLSL",
"-DINLINE=inline",
@ -413,6 +414,7 @@
"-DHAVE_GFX_WIDGETS",
"-DOSX",
"-DHAVE_OPENGL",
"-DHAVE_OPENGL1",
"-DHAVE_CC_RESAMPLER",
"-DHAVE_GLSL",
"-DINLINE=inline",