Merge pull request #1603 from reicast/fh/gles-dynload

Fix build errors on GL ES 2.0 platforms (RPi...)
This commit is contained in:
flyinghead 2019-05-17 12:15:07 +02:00 committed by GitHub
commit a6b773a23e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 15 deletions

View File

@ -438,3 +438,7 @@
#define SH4_RAM_CLOCK (100*1000*1000) //[100000000] XTal(13.5) -> PLL (33.3) -> PLL 1:3 (100) , also suplied to HOLLY chip #define SH4_RAM_CLOCK (100*1000*1000) //[100000000] XTal(13.5) -> PLL (33.3) -> PLL 1:3 (100) , also suplied to HOLLY chip
#define G2_BUS_CLOCK (25*1000*1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls #define G2_BUS_CLOCK (25*1000*1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls
#if defined(GLES) && !defined(GLES3)
// Only use GL ES 2.0 API functions
#define GLES2
#endif

View File

@ -2,10 +2,11 @@
#include <GLES32/gl32.h> #include <GLES32/gl32.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include "gl32funcs.h" #include "gl32funcs.h"
#include "build.h"
void load_gles_symbols() void load_gles_symbols()
{ {
#ifdef _ANDROID #ifdef GLES3
for (int i = 0; rglgen_symbol_map[i].sym != NULL; i++) for (int i = 0; rglgen_symbol_map[i].sym != NULL; i++)
*(void **)rglgen_symbol_map[i].ptr = eglGetProcAddress(rglgen_symbol_map[i].sym); *(void **)rglgen_symbol_map[i].ptr = eglGetProcAddress(rglgen_symbol_map[i].sym);
#endif #endif

View File

@ -948,9 +948,10 @@ void SetMVS_Mode(ModifierVolumeMode mv_mode, ISP_Modvol ispc)
static void SetupMainVBO() static void SetupMainVBO()
{ {
#ifndef GLES2
if (gl.gl_major >= 3) if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao); glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck(); glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck();
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl.vbo.idxs); glCheck(); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gl.vbo.idxs); glCheck();
@ -970,9 +971,10 @@ static void SetupMainVBO()
void SetupModvolVBO() void SetupModvolVBO()
{ {
#ifndef GLES2
if (gl.gl_major >= 3) if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao); glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.modvols); glCheck(); glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.modvols); glCheck();
//setup vertex buffers attrib pointers //setup vertex buffers attrib pointers

View File

@ -564,6 +564,7 @@ GLuint fogTextureId;
return false; return false;
} }
#ifdef GLES #ifdef GLES
// EGL only supports runtime loading with android? TDB
load_gles_symbols(); load_gles_symbols();
#else #else
egl_makecurrent(); egl_makecurrent();
@ -1202,7 +1203,9 @@ bool gl_create_resources()
//create vao //create vao
//This is really not "proper", vaos are supposed to be defined once //This is really not "proper", vaos are supposed to be defined once
//i keep updating the same one to make the es2 code work in 3.1 context //i keep updating the same one to make the es2 code work in 3.1 context
#ifndef GLES2
glGenVertexArrays(1, &gl.vbo.vao); glGenVertexArrays(1, &gl.vbo.vao);
#endif
} }
//create vbos //create vbos
@ -2001,8 +2004,10 @@ struct glesrend : Renderer
void DrawOSD(bool clear_screen) void DrawOSD(bool clear_screen)
{ {
#ifndef GLES2
if (gl.gl_major >= 3) if (gl.gl_major >= 3)
glBindVertexArray(gl.vbo.vao); glBindVertexArray(gl.vbo.vao);
#endif
glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck(); glBindBuffer(GL_ARRAY_BUFFER, gl.vbo.geometry); glCheck();
glEnableVertexAttribArray(VERTEX_POS_ARRAY); glEnableVertexAttribArray(VERTEX_POS_ARRAY);
glVertexAttribPointer(VERTEX_POS_ARRAY, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,x)); glVertexAttribPointer(VERTEX_POS_ARRAY, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex,x));

View File

@ -17,7 +17,9 @@
#endif #endif
#include <GLES32/gl32.h> #include <GLES32/gl32.h>
#include <GLES32/gl2ext.h> #include <GLES32/gl2ext.h>
#ifndef GLES2
#include "gl32funcs.h" #include "gl32funcs.h"
#endif
#ifndef GL_NV_draw_path #ifndef GL_NV_draw_path
//IMGTEC GLES emulation //IMGTEC GLES emulation

View File

@ -141,6 +141,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
if (save_background) if (save_background)
{ {
#ifndef GLES2
if (!gl.is_gles && glReadBuffer != NULL) if (!gl.is_gles && glReadBuffer != NULL)
glReadBuffer(GL_FRONT); glReadBuffer(GL_FRONT);
@ -157,6 +158,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
// Copy the current framebuffer into it // Copy the current framebuffer into it
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, fb_width, fb_height); glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, fb_width, fb_height);
#endif
} }
// Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill // Setup render state: alpha-blending enabled, no face culling, no depth testing, scissor enabled, polygon fill
@ -188,10 +190,12 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
glcache.UseProgram(g_ShaderHandle); glcache.UseProgram(g_ShaderHandle);
glUniform1i(g_AttribLocationTex, 0); glUniform1i(g_AttribLocationTex, 0);
glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]); glUniformMatrix4fv(g_AttribLocationProjMtx, 1, GL_FALSE, &ortho_projection[0][0]);
#ifndef GLES2
if (gl.gl_major >= 3 && glBindSampler != NULL) if (gl.gl_major >= 3 && glBindSampler != NULL)
glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise. glBindSampler(0, 0); // We use combined texture/sampler state. Applications using GL 3.3 may set that otherwise.
#endif
GLuint vao_handle = 0; GLuint vao_handle = 0;
#ifndef GLES2
if (gl.gl_major >= 3) if (gl.gl_major >= 3)
{ {
// Recreate the VAO every time // Recreate the VAO every time
@ -199,6 +203,7 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
glGenVertexArrays(1, &vao_handle); glGenVertexArrays(1, &vao_handle);
glBindVertexArray(vao_handle); glBindVertexArray(vao_handle);
} }
#endif
glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle); glBindBuffer(GL_ARRAY_BUFFER, g_VboHandle);
glEnableVertexAttribArray(g_AttribLocationPosition); glEnableVertexAttribArray(g_AttribLocationPosition);
glEnableVertexAttribArray(g_AttribLocationUV); glEnableVertexAttribArray(g_AttribLocationUV);
@ -247,8 +252,10 @@ void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data, bool save_backgr
idx_buffer_offset += pcmd->ElemCount; idx_buffer_offset += pcmd->ElemCount;
} }
} }
#ifndef GLES2
if (vao_handle != 0) if (vao_handle != 0)
glDeleteVertexArrays(1, &vao_handle); glDeleteVertexArrays(1, &vao_handle);
#endif
} }
bool ImGui_ImplOpenGL3_CreateFontsTexture() bool ImGui_ImplOpenGL3_CreateFontsTexture()

View File

@ -76,19 +76,15 @@ ifdef CHD5_FLAC
endif endif
ifdef NAOMI ifdef NAOMI
LOCAL_CFLAGS += -DTARGET_NAOMI=1 LOCAL_CFLAGS += -DTARGET_NAOMI=1
LOCAL_CPPFLAGS += -DTARGET_NAOMI=1
LOCAL_CXXFLAGS += -DTARGET_NAOMI=1
endif endif
# LOCAL_CFLAGS += -std=c++11 LOCAL_CFLAGS += -DGLES3
LOCAL_CXXFLAGS += -std=c++11 -fopenmp LOCAL_CXXFLAGS += -std=c++11 -fopenmp
LOCAL_LDFLAGS += -fopenmp LOCAL_LDFLAGS += -fopenmp
ifeq ($(TARGET_ARCH_ABI),x86) ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_CFLAGS+= -DTARGET_NO_AREC -DTARGET_NO_OPENMP LOCAL_CFLAGS+= -DTARGET_NO_AREC -DTARGET_NO_OPENMP
LOCAL_CXXFLAGS+= -DTARGET_NO_AREC -fpermissive -DTARGET_NO_OPENMP
LOCAL_CPPFLAGS+= -DTARGET_NO_AREC -DTARGET_NO_OPENMP
endif endif
LOCAL_CPP_FEATURES := LOCAL_CPP_FEATURES :=

View File

@ -171,8 +171,7 @@ else ifneq (,$(findstring rpi,$(platform)))
INCS += -I/opt/vc/include/ -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads INCS += -I/opt/vc/include/ -I/opt/vc/include/interface/vmcs_host/linux -I/opt/vc/include/interface/vcos/pthreads
LIBS += -L/opt/vc/lib/ -lbcm_host -ldl LIBS += -L/opt/vc/lib/ -lbcm_host -ldl
LIBS += -lbrcmEGL -lbrcmGLESv2 LIBS += -lbrcmEGL -lbrcmGLESv2
CFLAGS += -D TARGET_VIDEOCORE CFLAGS += -D TARGET_VIDEOCORE -DGLES
CXXFLAGS += -DGLES
USE_OMX := 1 USE_OMX := 1
USE_DISPMANX := 1 USE_DISPMANX := 1
endif endif
@ -208,7 +207,7 @@ else ifneq (,$(findstring odroid,$(platform)))
ifneq (,$(findstring odroidxu3,$(platform))) ifneq (,$(findstring odroidxu3,$(platform)))
MFLAGS += -march=armv7ve -mtune=cortex-a15.cortex-a7 MFLAGS += -march=armv7ve -mtune=cortex-a15.cortex-a7
ASFLAGS += -march=armv7ve ASFLAGS += -march=armv7ve
CFLAGS += -DGLES3
# Other ODROIDs # Other ODROIDs
else else
MFLAGS += -march=armv7-a MFLAGS += -march=armv7-a
@ -382,7 +381,7 @@ endif
# GLES on x11? # GLES on x11?
ifdef USE_GLES ifdef USE_GLES
CXXFLAGS += -DGLES CFLAGS += -DGLES
LIBS += -lEGL -lGLESv2 LIBS += -lEGL -lGLESv2
else ifdef FOR_LINUX else ifdef FOR_LINUX
LIBS += -ldl -lGL #for desktop gl LIBS += -ldl -lGL #for desktop gl