gsdx-ogl: restore gles build

Add the --gles build option to the linux main script
Ifdef all gl code not supported on gles3 (note some will be reenabled for gles3.1)

Note: it probably doesn't run anymore. My Nvidia driver doesn't support
yet egl/gles so I can't test it. Feel free to contribute.
This commit is contained in:
Gregory Hainaut 2014-03-29 11:24:39 +01:00
parent 483b5a75e8
commit b020bd76c6
9 changed files with 64 additions and 26 deletions

View File

@ -20,34 +20,26 @@ clean_build=false
for f in $* for f in $*
do do
case $f in case $f in
--dev|--devel) --dev|--devel ) flags="$flags -DCMAKE_BUILD_TYPE=Devel" ;;
flags="$flags -DCMAKE_BUILD_TYPE=Devel" --dbg|--debug ) flags="$flags -DCMAKE_BUILD_TYPE=Debug" ;;
;; --release ) flags="$flags -DCMAKE_BUILD_TYPE=Release" ;;
--dbg|--debug) --glsl ) flags="$flags -DGLSL_API=TRUE" ;;
flags="$flags -DCMAKE_BUILD_TYPE=Debug" --egl ) flags="$flags -DEGL_API=TRUE" ;;
;; --gles ) flags="$flags -DGLES_API=TRUE" ;;
--release) --sdl2 ) flags="$flags -DSDL2_API=TRUE" ;;
flags="$flags -DCMAKE_BUILD_TYPE=Release" --clean ) clean_build=true ;;
;;
--glsl)
flags="$flags -DGLSL_API=TRUE"
;;
--egl)
echo "Warning EGL needs at lesat MESA 9.0"
flags="$flags -DEGL_API=TRUE"
;;
--clean)
clean_build=true
;;
*) *)
# unknown option # unknown option
echo "Valid options are:" echo "** User options **"
echo "--dev / --devel - Build PCSX2 as a Development build." echo "--dev / --devel : Build PCSX2 as a Development build."
echo "--debug - Build PCSX2 as a Debug build." echo "--debug : Build PCSX2 as a Debug build."
echo "--release - Build PCSX2 as a Release build." echo "--release : Build PCSX2 as a Release build."
echo "--clean - Do a clean build." echo "--clean : Do a clean build."
echo "--glsl - Replace CG backend of ZZogl by GLSL" echo "** Developper option **"
echo "--egl - Replace GLX by EGL (ZZogl plugins only)" echo "--glsl : Replace CG backend of ZZogl by GLSL"
echo "--egl : Replace GLX by EGL (ZZogl plugins only)"
echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)"
echo "--gles : Replace openGL backend of GSdx by openGLES3"
exit 1;; exit 1;;
esac esac
done done

View File

@ -211,7 +211,9 @@ extern PFNGLDEPTHRANGEDNVPROC gl_DepthRangedNV;
#define gl_CheckFramebufferStatus glCheckFramebufferStatus #define gl_CheckFramebufferStatus glCheckFramebufferStatus
#define gl_ClearBufferfv glClearBufferfv #define gl_ClearBufferfv glClearBufferfv
#define gl_ClearBufferiv glClearBufferiv #define gl_ClearBufferiv glClearBufferiv
#define gl_ClearBufferuiv glClearBufferuiv
#define gl_CompileShader glCompileShader #define gl_CompileShader glCompileShader
#define gl_ColorMask glColorMask
#define gl_CreateProgram glCreateProgram #define gl_CreateProgram glCreateProgram
#define gl_CreateShader glCreateShader #define gl_CreateShader glCreateShader
#define gl_CreateShaderProgramv glCreateShaderProgramv #define gl_CreateShaderProgramv glCreateShaderProgramv

View File

@ -487,6 +487,7 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
// TODO is it possible with GL44 ClearTexture? no the API is garbage! // TODO is it possible with GL44 ClearTexture? no the API is garbage!
// Anyway, stencil can be cleared to 0 (it will be only used for date) // Anyway, stencil can be cleared to 0 (it will be only used for date)
if (0 && GLLoader::found_GL_ARB_clear_texture) { if (0 && GLLoader::found_GL_ARB_clear_texture) {
#ifndef ENABLE_GLES
static_cast<GSTextureOGL*>(t)->EnableUnit(); static_cast<GSTextureOGL*>(t)->EnableUnit();
// Yes a very nice API to mix float and integer // Yes a very nice API to mix float and integer
struct clear { struct clear {
@ -498,6 +499,7 @@ void GSDeviceOGL::ClearDepth(GSTexture* t, float c)
clear.stencil = 0; clear.stencil = 0;
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, &clear); gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, &clear);
#endif
} else { } else {
OMSetFBO(m_fbo); OMSetFBO(m_fbo);
OMSetWriteBuffer(); OMSetWriteBuffer();
@ -519,8 +521,10 @@ void GSDeviceOGL::ClearStencil(GSTexture* t, uint8 c)
{ {
// TODO is it possible with GL44 ClearTexture? no the API is garbage! // TODO is it possible with GL44 ClearTexture? no the API is garbage!
if (GLLoader::found_GL_ARB_clear_texture) { if (GLLoader::found_GL_ARB_clear_texture) {
#ifndef ENABLE_GLES
static_cast<GSTextureOGL*>(t)->EnableUnit(); static_cast<GSTextureOGL*>(t)->EnableUnit();
gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_BYTE, &c); gl_ClearTexImage(static_cast<GSTextureOGL*>(t)->GetID(), 0, GL_DEPTH_STENCIL, GL_BYTE, &c);
#endif
} else { } else {
OMSetFBO(m_fbo); OMSetFBO(m_fbo);
OMSetWriteBuffer(); OMSetWriteBuffer();
@ -600,7 +604,9 @@ void GSDeviceOGL::BindDateTexture()
// gl_BindImageTextures(2, 1, textures); // gl_BindImageTextures(2, 1, textures);
//gl_BindImageTexture(2, 0, 0, true, 0, GL_READ_WRITE, GL_R32I); //gl_BindImageTexture(2, 0, 0, true, 0, GL_READ_WRITE, GL_R32I);
#ifndef ENABLE_GLES
gl_BindImageTexture(2, static_cast<GSTextureOGL*>(m_date.t)->GetID(), 0, false, 0, GL_READ_WRITE, GL_R32I); gl_BindImageTexture(2, static_cast<GSTextureOGL*>(m_date.t)->GetID(), 0, false, 0, GL_READ_WRITE, GL_R32I);
#endif
} }
void GSDeviceOGL::RecycleDateTexture() void GSDeviceOGL::RecycleDateTexture()
@ -618,11 +624,13 @@ void GSDeviceOGL::RecycleDateTexture()
void GSDeviceOGL::Barrier(GLbitfield b) void GSDeviceOGL::Barrier(GLbitfield b)
{ {
#ifndef ENABLE_GLES
gl_MemoryBarrier(b); gl_MemoryBarrier(b);
//#ifdef ENABLE_OGL_STENCIL_DEBUG //#ifdef ENABLE_OGL_STENCIL_DEBUG
// if (m_date.t) // if (m_date.t)
// static_cast<GSTextureOGL*>(m_date.t)->Save(format("/tmp/barrier_%04ld.csv", g_draw_count)); // static_cast<GSTextureOGL*>(m_date.t)->Save(format("/tmp/barrier_%04ld.csv", g_draw_count));
//#endif //#endif
#endif
} }
/* Note: must be here because tfx_glsl is static */ /* Note: must be here because tfx_glsl is static */
@ -1027,7 +1035,9 @@ void GSDeviceOGL::PSSetShaderResource(GLuint sr)
GLState::tex_unit[0] = sr; GLState::tex_unit[0] = sr;
if (GLLoader::found_GL_ARB_multi_bind) { if (GLLoader::found_GL_ARB_multi_bind) {
#ifndef ENABLE_GLES
gl_BindTextures(0, 1, &sr); gl_BindTextures(0, 1, &sr);
#endif
} else { } else {
gl_ActiveTexture(GL_TEXTURE0); gl_ActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, sr); glBindTexture(GL_TEXTURE_2D, sr);
@ -1045,7 +1055,9 @@ void GSDeviceOGL::PSSetShaderResources(GLuint tex[2])
GLState::tex_unit[1] = tex[1]; GLState::tex_unit[1] = tex[1];
if (GLLoader::found_GL_ARB_multi_bind) { if (GLLoader::found_GL_ARB_multi_bind) {
#ifndef ENABLE_GLES
gl_BindTextures(0, 2, tex); gl_BindTextures(0, 2, tex);
#endif
} else { } else {
gl_ActiveTexture(GL_TEXTURE0); gl_ActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex[0]); glBindTexture(GL_TEXTURE_2D, tex[0]);

View File

@ -106,7 +106,11 @@ public:
GLState::b_msk = m_b_msk; GLState::b_msk = m_b_msk;
GLState::a_msk = m_a_msk; GLState::a_msk = m_a_msk;
#ifdef ENABLE_GLES
gl_ColorMask(m_r_msk, m_g_msk, m_b_msk, m_a_msk);
#else
gl_ColorMaski(0, m_r_msk, m_g_msk, m_b_msk, m_a_msk); gl_ColorMaski(0, m_r_msk, m_g_msk, m_b_msk, m_a_msk);
#endif
} }
} }
@ -133,7 +137,11 @@ public:
if (GLState::eq_RGB != m_equation_RGB || GLState::eq_A != m_equation_A) { if (GLState::eq_RGB != m_equation_RGB || GLState::eq_A != m_equation_A) {
GLState::eq_RGB = m_equation_RGB; GLState::eq_RGB = m_equation_RGB;
GLState::eq_A = m_equation_A; GLState::eq_A = m_equation_A;
#ifdef ENABLE_GLES
gl_BlendEquationSeparate(m_equation_RGB, m_equation_A);
#else
gl_BlendEquationSeparateiARB(0, m_equation_RGB, m_equation_A); gl_BlendEquationSeparateiARB(0, m_equation_RGB, m_equation_A);
#endif
} }
// FIXME align then SSE // FIXME align then SSE
if (GLState::f_sRGB != m_func_sRGB || GLState::f_dRGB != m_func_dRGB || GLState::f_sA != m_func_sA || GLState::f_dA != m_func_dA) { if (GLState::f_sRGB != m_func_sRGB || GLState::f_dRGB != m_func_dRGB || GLState::f_sA != m_func_sA || GLState::f_dA != m_func_dA) {
@ -141,7 +149,11 @@ public:
GLState::f_dRGB = m_func_dRGB; GLState::f_dRGB = m_func_dRGB;
GLState::f_sA = m_func_sA; GLState::f_sA = m_func_sA;
GLState::f_dA = m_func_dA; GLState::f_dA = m_func_dA;
#ifdef ENABLE_GLES
gl_BlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sA, m_func_dA);
#else
gl_BlendFuncSeparateiARB(0, m_func_sRGB, m_func_dRGB, m_func_sA, m_func_dA); gl_BlendFuncSeparateiARB(0, m_func_sRGB, m_func_dRGB, m_func_sA, m_func_dA);
#endif
} }
} }
} }

View File

@ -522,8 +522,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
dev->SetupPS(ps_sel); dev->SetupPS(ps_sel);
// Be sure that first pass is finished ! // Be sure that first pass is finished !
#ifndef ENABLE_GLES
if (!UserHacks_DateGL4) if (!UserHacks_DateGL4)
dev->Barrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT); dev->Barrier(GL_SHADER_IMAGE_ACCESS_BARRIER_BIT);
#endif
} }
if(context->TEST.DoFirstPass()) if(context->TEST.DoFirstPass())

View File

@ -153,6 +153,7 @@ void GSShaderOGL::SetSamplerBinding(GLuint prog, GLchar* name, GLuint binding)
void GSShaderOGL::SetupRessources() void GSShaderOGL::SetupRessources()
{ {
#ifndef ENABLE_GLES
if (!GLLoader::found_GL_ARB_bindless_texture) return; if (!GLLoader::found_GL_ARB_bindless_texture) return;
if (GLState::dirty_ressources) { if (GLState::dirty_ressources) {
@ -166,6 +167,7 @@ void GSShaderOGL::SetupRessources()
gl_UniformHandleui64vARB(0, count, GLState::tex_handle); gl_UniformHandleui64vARB(0, count, GLState::tex_handle);
} }
} }
#endif
} }
void GSShaderOGL::SetupUniform() void GSShaderOGL::SetupUniform()
@ -201,6 +203,7 @@ void GSShaderOGL::SetupUniform()
void GSShaderOGL::SetupSubroutineUniform() void GSShaderOGL::SetupSubroutineUniform()
{ {
#ifndef ENABLE_GLES
if (!GLLoader::found_GL_ARB_shader_subroutine) return; if (!GLLoader::found_GL_ARB_shader_subroutine) return;
if (GLState::dirty_subroutine_vs && m_vs_sub_count) { if (GLState::dirty_subroutine_vs && m_vs_sub_count) {
@ -212,6 +215,7 @@ void GSShaderOGL::SetupSubroutineUniform()
gl_UniformSubroutinesuiv(GL_FRAGMENT_SHADER, m_ps_sub_count, m_ps_sub); gl_UniformSubroutinesuiv(GL_FRAGMENT_SHADER, m_ps_sub_count, m_ps_sub);
GLState::dirty_subroutine_ps = false; GLState::dirty_subroutine_ps = false;
} }
#endif
} }
bool GSShaderOGL::ValidateShader(GLuint s) bool GSShaderOGL::ValidateShader(GLuint s)

View File

@ -65,9 +65,11 @@ void GSDeviceOGL::CreateTextureFX()
// because of -1 we loose lot of precision for small GS value // because of -1 we loose lot of precision for small GS value
// This extension allow FS depth to range from -1 to 1. So // This extension allow FS depth to range from -1 to 1. So
// gl_position.z could range from [0, 1] // gl_position.z could range from [0, 1]
#ifndef ENABLE_GLES
if (GLLoader::found_GL_NV_depth_buffer_float) { if (GLLoader::found_GL_NV_depth_buffer_float) {
gl_DepthRangedNV(-1.0f, 1.0f); gl_DepthRangedNV(-1.0f, 1.0f);
} }
#endif
} }
GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel) GSDepthStencilOGL* GSDeviceOGL::CreateDepthStencil(OMDepthStencilSelector dssel)

View File

@ -40,11 +40,13 @@ namespace PboPool {
const uint32 m_pbo_size = (640*480*16) << 2; const uint32 m_pbo_size = (640*480*16) << 2;
bool m_buffer_storage = false; bool m_buffer_storage = false;
#ifndef ENABLE_GLES
// Option for buffer storage // Option for buffer storage
// Note there is a barrier (but maybe coherent is faster) // Note there is a barrier (but maybe coherent is faster)
const GLbitfield map_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; const GLbitfield map_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
// FIXME do I need GL_DYNAMIC_STORAGE_BIT to allow write? // FIXME do I need GL_DYNAMIC_STORAGE_BIT to allow write?
const GLbitfield create_flags = map_flags | GL_DYNAMIC_STORAGE_BIT; const GLbitfield create_flags = map_flags | GL_DYNAMIC_STORAGE_BIT;
#endif
// Normally driver must aligned the map.... // Normally driver must aligned the map....
void* align_map(void* ptr) { void* align_map(void* ptr) {
@ -66,10 +68,12 @@ namespace PboPool {
// Note the +64 gives additional room to realign the buffer (buggy driver....) // Note the +64 gives additional room to realign the buffer (buggy driver....)
if (m_buffer_storage) { if (m_buffer_storage) {
#ifndef ENABLE_GLES
gl_BufferStorage(GL_PIXEL_UNPACK_BUFFER, m_pbo_size+64, NULL, create_flags); gl_BufferStorage(GL_PIXEL_UNPACK_BUFFER, m_pbo_size+64, NULL, create_flags);
m_map[m_current_pbo] = (char*)align_map(gl_MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_pbo_size+64, map_flags)); m_map[m_current_pbo] = (char*)align_map(gl_MapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, m_pbo_size+64, map_flags));
// Workaround silly driver. (would be 0 otherwise) // Workaround silly driver. (would be 0 otherwise)
m_offset[m_current_pbo] = m_initial_offset[m_current_pbo]; m_offset[m_current_pbo] = m_initial_offset[m_current_pbo];
#endif
} else { } else {
gl_BufferData(GL_PIXEL_UNPACK_BUFFER, m_pbo_size+64, NULL, GL_STREAM_COPY); gl_BufferData(GL_PIXEL_UNPACK_BUFFER, m_pbo_size+64, NULL, GL_STREAM_COPY);
m_map[m_current_pbo] = NULL; m_map[m_current_pbo] = NULL;
@ -317,8 +321,10 @@ GSTextureOGL::~GSTextureOGL()
void GSTextureOGL::Clear(const void *data) void GSTextureOGL::Clear(const void *data)
{ {
#ifndef ENABLE_GLES
EnableUnit(); EnableUnit();
gl_ClearTexImage(m_texture_id, 0, m_int_format, m_int_type, data); gl_ClearTexImage(m_texture_id, 0, m_int_format, m_int_type, data);
#endif
} }
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch) bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
@ -380,10 +386,12 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
GLuint64 GSTextureOGL::GetHandle(GLuint sampler_id) GLuint64 GSTextureOGL::GetHandle(GLuint sampler_id)
{ {
ASSERT(sampler_id < 12); ASSERT(sampler_id < 12);
#ifndef ENABLE_GLES
if (!m_handles[sampler_id]) { if (!m_handles[sampler_id]) {
m_handles[sampler_id] = gl_GetTextureSamplerHandleARB(m_texture_id, sampler_id); m_handles[sampler_id] = gl_GetTextureSamplerHandleARB(m_texture_id, sampler_id);
gl_MakeTextureHandleResidentARB(m_handles[sampler_id]); gl_MakeTextureHandleResidentARB(m_handles[sampler_id]);
} }
#endif
return m_handles[sampler_id]; return m_handles[sampler_id];
} }
@ -613,8 +621,10 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
gl_ActiveTexture(GL_TEXTURE0 + 6); gl_ActiveTexture(GL_TEXTURE0 + 6);
glBindTexture(GL_TEXTURE_2D, m_texture_id); glBindTexture(GL_TEXTURE_2D, m_texture_id);
#ifndef ENABLE_GLES
glGetTexImage(GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_INT, image); glGetTexImage(GL_TEXTURE_2D, 0, GL_RED_INTEGER, GL_INT, image);
SaveRaw(fn, image, pitch); SaveRaw(fn, image, pitch);
#endif
// Not supported in Save function // Not supported in Save function
status = false; status = false;

View File

@ -63,6 +63,7 @@ class GSBufferOGL {
m_limit = 2 * 2 * 1024 * 1024 / m_stride; m_limit = 2 * 2 * 1024 * 1024 / m_stride;
if (m_buffer_storage) { if (m_buffer_storage) {
#ifndef ENABLE_GLES
bind(); bind();
// FIXME do I need the dynamic // FIXME do I need the dynamic
const GLbitfield map_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT; const GLbitfield map_flags = GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT;
@ -70,6 +71,7 @@ class GSBufferOGL {
gl_BufferStorage(m_target, m_stride*m_limit, NULL, create_flags ); gl_BufferStorage(m_target, m_stride*m_limit, NULL, create_flags );
m_buffer_ptr = (uint8*) gl_MapBufferRange(m_target, 0, m_stride*m_limit, map_flags); m_buffer_ptr = (uint8*) gl_MapBufferRange(m_target, 0, m_stride*m_limit, map_flags);
#endif
} else { } else {
m_buffer_ptr = NULL; m_buffer_ptr = NULL;
} }