mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
[Android] Start of *working* GLES3 support. Needs to be able to compile in Windows still.
This commit is contained in:
@ -24,9 +24,10 @@ if(USE_EGL)
|
||||
EGL)
|
||||
endif()
|
||||
|
||||
if(USE_GLES)
|
||||
if(USE_GLES3)
|
||||
set(LIBS ${LIBS}
|
||||
GLESv2)
|
||||
set(SRCS ${SRCS} Src/GLFunctions.cpp)
|
||||
else()
|
||||
set(LIBS ${LIBS}
|
||||
GLEW
|
||||
|
93
Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp
Normal file
93
Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
#include "GLFunctions.h"
|
||||
#include "Log.h"
|
||||
#ifdef USE_GLES3
|
||||
PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
|
||||
|
||||
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
||||
|
||||
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
|
||||
PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
|
||||
PFNGLDELETESYNCPROC glDeleteSync;
|
||||
PFNGLFENCESYNCPROC glFenceSync;
|
||||
|
||||
PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
|
||||
PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
|
||||
PFNGLSAMPLERPARAMETERFVPROC glSamplerParameterfv;
|
||||
PFNGLBINDSAMPLERPROC glBindSampler;
|
||||
PFNGLDELETESAMPLERSPROC glDeleteSamplers;
|
||||
PFNGLGENSAMPLERSPROC glGenSamplers;
|
||||
|
||||
PFNGLGETPROGRAMBINARYPROC glGetProgramBinary;
|
||||
PFNGLPROGRAMBINARYPROC glProgramBinary;
|
||||
PFNGLPROGRAMPARAMETERIPROC glProgramParameteri;
|
||||
|
||||
PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
|
||||
PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
|
||||
|
||||
PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
PFNGLENDQUERYPROC glEndQuery;
|
||||
PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
|
||||
PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
PFNGLGENQUERIESPROC glGenQueries;
|
||||
#endif
|
||||
namespace GLFunc
|
||||
{
|
||||
void LoadFunction(const char *name, void **func)
|
||||
{
|
||||
#ifdef USE_GLES3
|
||||
*func = (void*)eglGetProcAddress(name);
|
||||
if (*func == NULL)
|
||||
{
|
||||
ERROR_LOG(VIDEO, "Couldn't load function %s", name);
|
||||
exit(0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
LoadFunction("glBeginQuery", (void**)&glBeginQuery);
|
||||
LoadFunction("glEndQuery", (void**)&glEndQuery);
|
||||
LoadFunction("glGetQueryObjectuiv", (void**)&glGetQueryObjectuiv);
|
||||
LoadFunction("glDeleteQueries", (void**)&glDeleteQueries);
|
||||
LoadFunction("glGenQueries", (void**)&glGenQueries);
|
||||
{
|
||||
LoadFunction("glMapBuffer", (void**)&glMapBuffer);
|
||||
LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer);
|
||||
LoadFunction("glMapBufferRange", (void**)&glMapBufferRange);
|
||||
LoadFunction("glBindBufferRange", (void**)&glBindBufferRange);
|
||||
|
||||
LoadFunction("glBlitFramebuffer", (void**)&glBlitFramebuffer);
|
||||
|
||||
LoadFunction("glGenVertexArrays", (void**)&glGenVertexArrays);
|
||||
LoadFunction("glDeleteVertexArrays", (void**)&glDeleteVertexArrays);
|
||||
LoadFunction("glBindVertexArray", (void**)&glBindVertexArray);
|
||||
|
||||
LoadFunction("glClientWaitSync", (void**)&glClientWaitSync);
|
||||
LoadFunction("glDeleteSync", (void**)&glDeleteSync);
|
||||
LoadFunction("glFenceSync", (void**)&glFenceSync);
|
||||
LoadFunction("glSamplerParameterf", (void**)&glSamplerParameterf);
|
||||
LoadFunction("glSamplerParameteri", (void**)&glSamplerParameteri);
|
||||
LoadFunction("glSamplerParameterfv", (void**)&glSamplerParameterfv);
|
||||
LoadFunction("glBindSampler", (void**)&glBindSampler);
|
||||
LoadFunction("glDeleteSamplers", (void**)&glDeleteSamplers);
|
||||
LoadFunction("glGenSamplers", (void**)&glGenSamplers);
|
||||
}
|
||||
|
||||
LoadFunction("glGetProgramBinary", (void**)&glGetProgramBinary);
|
||||
LoadFunction("glProgramBinary", (void**)&glProgramBinary);
|
||||
LoadFunction("glProgramParameteri", (void**)&glProgramParameteri);
|
||||
|
||||
LoadFunction("glGetUniformBlockIndex", (void**)&glGetUniformBlockIndex);
|
||||
LoadFunction("glUniformBlockBinding", (void**)&glUniformBlockBinding);
|
||||
}
|
||||
}
|
90
Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.h
Normal file
90
Source/Plugins/Plugin_VideoOGL/Src/GLFunctions.h
Normal file
@ -0,0 +1,90 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
#ifndef GLFUNCTIONS_H_
|
||||
#define GLFUNCTIONS_H_
|
||||
#include "GLInterface.h"
|
||||
|
||||
#ifdef USE_GLES3
|
||||
typedef GLvoid* (*PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
|
||||
typedef GLvoid* (*PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
typedef void (*PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
typedef GLboolean (*PFNGLUNMAPBUFFERPROC) (GLenum target);
|
||||
|
||||
typedef void (*PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
// VAOS
|
||||
typedef void (*PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint* arrays);
|
||||
typedef void (*PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint* arrays);
|
||||
typedef void (*PFNGLBINDVERTEXARRAYPROC) (GLuint array);
|
||||
|
||||
// Sync
|
||||
typedef GLenum (*PFNGLCLIENTWAITSYNCPROC) (GLsync GLsync,GLbitfield flags,GLuint64 timeout);
|
||||
typedef void (*PFNGLDELETESYNCPROC) (GLsync GLsync);
|
||||
typedef GLsync (*PFNGLFENCESYNCPROC) (GLenum condition,GLbitfield flags);
|
||||
|
||||
//Sampler
|
||||
typedef void (*PFNGLSAMPLERPARAMETERFPROC) (GLuint sampler, GLenum pname, GLfloat param);
|
||||
typedef void (*PFNGLSAMPLERPARAMETERIPROC) (GLuint sampler, GLenum pname, GLint param);
|
||||
typedef void (*PFNGLSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum pname, const GLfloat* params);
|
||||
typedef void (*PFNGLBINDSAMPLERPROC) (GLuint unit, GLuint sampler);
|
||||
typedef void (*PFNGLDELETESAMPLERSPROC) (GLsizei count, const GLuint * samplers);
|
||||
typedef void (*PFNGLGENSAMPLERSPROC) (GLsizei count, GLuint* samplers);
|
||||
|
||||
//Program binar
|
||||
typedef void (*PFNGLGETPROGRAMBINARYPROC) (GLuint program, GLsizei bufSize, GLsizei* length, GLenum *binaryFormat, GLvoid*binary);
|
||||
typedef void (*PFNGLPROGRAMBINARYPROC) (GLuint program, GLenum binaryFormat, const void* binary, GLsizei length);
|
||||
typedef void (*PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
|
||||
|
||||
typedef GLuint (*PFNGLGETUNIFORMBLOCKINDEXPROC) (GLuint program, const GLchar* uniformBlockName);
|
||||
typedef void (*PFNGLUNIFORMBLOCKBINDINGPROC) (GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
|
||||
|
||||
//Query
|
||||
typedef void (*PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
|
||||
typedef void (*PFNGLENDQUERYPROC) (GLenum target);
|
||||
typedef void (*PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint* params);
|
||||
typedef void (*PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint* ids);
|
||||
typedef void (*PFNGLGENQUERIESPROC) (GLsizei n, GLuint* ids);
|
||||
|
||||
// ptrs
|
||||
extern PFNGLBEGINQUERYPROC glBeginQuery;
|
||||
extern PFNGLENDQUERYPROC glEndQuery;
|
||||
extern PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
|
||||
extern PFNGLDELETEQUERIESPROC glDeleteQueries;
|
||||
extern PFNGLGENQUERIESPROC glGenQueries;
|
||||
|
||||
extern PFNGLMAPBUFFERPROC glMapBuffer;
|
||||
extern PFNGLUNMAPBUFFERPROC glUnmapBuffer;
|
||||
extern PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
|
||||
extern PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
|
||||
|
||||
extern PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
|
||||
|
||||
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
|
||||
extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
|
||||
extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
|
||||
|
||||
extern PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
|
||||
extern PFNGLDELETESYNCPROC glDeleteSync;
|
||||
extern PFNGLFENCESYNCPROC glFenceSync;
|
||||
|
||||
extern PFNGLGETPROGRAMBINARYPROC glGetProgramBinary;
|
||||
extern PFNGLPROGRAMBINARYPROC glProgramBinary;
|
||||
extern PFNGLPROGRAMPARAMETERIPROC glProgramParameteri;
|
||||
|
||||
//Sampler
|
||||
extern PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
|
||||
extern PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
|
||||
extern PFNGLSAMPLERPARAMETERFVPROC glSamplerParameterfv;
|
||||
extern PFNGLBINDSAMPLERPROC glBindSampler;
|
||||
extern PFNGLDELETESAMPLERSPROC glDeleteSamplers;
|
||||
extern PFNGLGENSAMPLERSPROC glGenSamplers;
|
||||
|
||||
extern PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
|
||||
extern PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
|
||||
#endif
|
||||
|
||||
namespace GLFunc
|
||||
{
|
||||
void Init();
|
||||
}
|
||||
#endif
|
@ -21,6 +21,9 @@
|
||||
#define PREC "highp"
|
||||
#define TEXTYPE "sampler2D"
|
||||
#define TEXFUNC "texture2D"
|
||||
#ifdef USE_GLES3
|
||||
#include "GLFunctions.h"
|
||||
#endif
|
||||
#else
|
||||
#define TEX2D GL_TEXTURE_RECTANGLE_ARB
|
||||
#define PREC
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "ProgramShaderCache.h"
|
||||
#include "DriverDetails"
|
||||
#include "MathUtil.h"
|
||||
#include "StreamBuffer.h"
|
||||
#include "Debugger.h"
|
||||
@ -532,15 +533,15 @@ void ProgramShaderCache::CreateHeader ( void )
|
||||
"%s\n"
|
||||
"%s\n"
|
||||
"#define COLOROUT(name) %s\n"
|
||||
|
||||
|
||||
, v==GLSLES3 ? "300 es" : v==GLSL_120 ? "120" : v==GLSL_130 ? "130" : "140"
|
||||
, v==GLSLES3 ? "precision highp float;" : ""
|
||||
, v==GLSLES3 ? "" : v<=GLSL_130 ? "#extension GL_ARB_texture_rectangle : enable" : "#define texture2DRect texture"
|
||||
, g_ActiveConfig.backend_info.bSupportsGLSLUBO && v<GLSL_140 ? "#extension GL_ARB_uniform_buffer_object : enable" : ""
|
||||
, v==GLSL_120 ? "attribute" : "in"
|
||||
, v==GLSL_120 ? "attribute" : "out"
|
||||
, v==GLSL_120 ? "varying" : "centroid in"
|
||||
, v==GLSL_120 ? "varying" : "centroid out"
|
||||
, DriverDetails::HasBug(BUG_BROKENCENTROID) ? "in" : v==GLSL_120 ? "varying" : "centroid in"
|
||||
, DriverDetails::HasBug(BUG_BROKENCENTROID) ? "out" : v==GLSL_120 ? "varying" : "centroid out"
|
||||
, v==GLSL_120 ? "#define texture texture2D" : ""
|
||||
, v==GLSL_120 ? "#define round(x) floor((x)+0.5f)" : ""
|
||||
, v==GLSL_120 ? "#define out " : ""
|
||||
|
@ -22,6 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include "CommonPaths.h"
|
||||
#include "DriverDetails.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "Statistics.h"
|
||||
#include "ImageWrite.h"
|
||||
@ -254,6 +255,53 @@ void ErrorCallback( GLenum source, GLenum type, GLuint id, GLenum severity, GLsi
|
||||
#endif
|
||||
}
|
||||
|
||||
void InitDriverInfo()
|
||||
{
|
||||
// Get Vendor
|
||||
std::string svendor = std::string(g_ogl_config.gl_vendor);
|
||||
std::string srenderer = std::string(g_ogl_config.gl_renderer);
|
||||
DriverDetails::Vendor vendor = DriverDetails::VENDOR_UNKNOWN;
|
||||
u32 devfamily = 0;
|
||||
double version = 0.0;
|
||||
|
||||
// Get Vendor first
|
||||
if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra")
|
||||
vendor = DriverDetails::VENDOR_NVIDIA;
|
||||
else if (svendor == "ATI Technologies Inc.")
|
||||
vendor = DriverDetails::VENDOR_ATI;
|
||||
else if (std::string::npos != svendor.find("Intel"))
|
||||
vendor = DriverDetails::VENDOR_INTEL;
|
||||
else if (svendor == "ARM")
|
||||
vendor = DriverDetails::VENDOR_ARM;
|
||||
else if (svendor == "Qualcomm")
|
||||
vendor = DriverDetails::VENDOR_QUALCOMM;
|
||||
else if (svendor == "Imagination Technologies")
|
||||
vendor = DriverDetails::VENDOR_IMGTEC;
|
||||
else if (svendor == "NVIDIA Corporation" && srenderer != "NVIDIA Tegra")
|
||||
vendor = DriverDetails::VENDOR_TEGRA;
|
||||
else if (svendor == "Vivante Corporation")
|
||||
vendor = DriverDetails::VENDOR_VIVANTE;
|
||||
|
||||
// Get device family and driver version...if we care about it
|
||||
switch(vendor)
|
||||
{
|
||||
case DriverDetails::VENDOR_QUALCOMM:
|
||||
{
|
||||
if (std::string::npos != srenderer.find("Adreno (TM) 3"))
|
||||
devfamily = 300;
|
||||
else
|
||||
devfamily = 200;
|
||||
double glVersion;
|
||||
sscanf(g_ogl_config.gl_version, "OpenGL ES %lg V@%lg", &glVersion, &version);
|
||||
}
|
||||
break;
|
||||
// We don't care about these
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DriverDetails::Init(vendor, devfamily, version);
|
||||
}
|
||||
|
||||
// Init functions
|
||||
Renderer::Renderer()
|
||||
{
|
||||
@ -271,10 +319,13 @@ Renderer::Renderer()
|
||||
g_ogl_config.gl_renderer = (const char*)glGetString(GL_RENDERER);
|
||||
g_ogl_config.gl_version = (const char*)glGetString(GL_VERSION);
|
||||
g_ogl_config.glsl_version = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
|
||||
|
||||
InitDriverInfo();
|
||||
|
||||
// Init extension support.
|
||||
#ifdef USE_GLES3
|
||||
// Set default GLES3 options
|
||||
GLFunc::Init();
|
||||
WARN_LOG(VIDEO, "Running the OpenGL ES 3 backend!");
|
||||
g_Config.backend_info.bSupportsDualSourceBlend = false;
|
||||
g_Config.backend_info.bSupportsGLSLUBO = true;
|
||||
@ -1432,7 +1483,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons
|
||||
DrawDebugText();
|
||||
|
||||
GL_REPORT_ERRORD();
|
||||
|
||||
|
||||
// Do our OSD callbacks
|
||||
OSD::DoCallbacks(OSD::OSD_ONFRAME);
|
||||
OSD::DrawMessages();
|
||||
|
Reference in New Issue
Block a user