~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/VideoBackends/OGL/Src/GLFunctions.cpp

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright 2013 Dolphin Emulator Project
 
2
// Licensed under GPLv2
 
3
// Refer to the license.txt file included.
 
4
 
 
5
#include "DriverDetails.h"
 
6
#include "GLFunctions.h"
 
7
#include "Log.h"
 
8
#include <dlfcn.h>
 
9
 
 
10
#ifdef USE_GLES3
 
11
PFNGLMAPBUFFERRANGEPROC glMapBufferRange;
 
12
PFNGLUNMAPBUFFERPROC glUnmapBuffer;
 
13
PFNGLBINDBUFFERRANGEPROC glBindBufferRange;
 
14
 
 
15
PFNGLBLITFRAMEBUFFERPROC glBlitFramebuffer;
 
16
 
 
17
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
 
18
PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
 
19
PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
 
20
 
 
21
PFNGLCLIENTWAITSYNCPROC glClientWaitSync;
 
22
PFNGLDELETESYNCPROC glDeleteSync;
 
23
PFNGLFENCESYNCPROC glFenceSync;
 
24
 
 
25
PFNGLSAMPLERPARAMETERFPROC glSamplerParameterf;
 
26
PFNGLSAMPLERPARAMETERIPROC glSamplerParameteri;
 
27
PFNGLSAMPLERPARAMETERFVPROC glSamplerParameterfv;
 
28
PFNGLBINDSAMPLERPROC glBindSampler;
 
29
PFNGLDELETESAMPLERSPROC glDeleteSamplers;
 
30
PFNGLGENSAMPLERSPROC glGenSamplers;
 
31
 
 
32
PFNGLGETPROGRAMBINARYPROC glGetProgramBinary;
 
33
PFNGLPROGRAMBINARYPROC glProgramBinary;
 
34
PFNGLPROGRAMPARAMETERIPROC glProgramParameteri;
 
35
 
 
36
PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
 
37
 
 
38
PFNGLRENDERBUFFERSTORAGEMULTISAMPLE glRenderbufferStorageMultisample;
 
39
 
 
40
PFNGLGETUNIFORMBLOCKINDEXPROC glGetUniformBlockIndex;
 
41
PFNGLUNIFORMBLOCKBINDINGPROC glUniformBlockBinding;
 
42
 
 
43
PFNGLBEGINQUERYPROC glBeginQuery;
 
44
PFNGLENDQUERYPROC glEndQuery;
 
45
PFNGLGETQUERYOBJECTUIVPROC glGetQueryObjectuiv;
 
46
PFNGLDELETEQUERIESPROC glDeleteQueries;
 
47
PFNGLGENQUERIESPROC glGenQueries;
 
48
#endif
 
49
namespace GLFunc
 
50
{
 
51
        void *self;
 
52
        void LoadFunction(const char *name, void **func)
 
53
        {
 
54
#ifdef USE_GLES3
 
55
                *func = (void*)eglGetProcAddress(name);
 
56
                if (*func == NULL)
 
57
                {
 
58
                        // Fall back to trying dlsym
 
59
                        if (self) // Just in case dlopen fails
 
60
                                *func = dlsym(self, name);
 
61
                        if (*func == NULL)
 
62
                        {
 
63
                                ERROR_LOG(VIDEO, "Couldn't load function %s", name);
 
64
                                exit(0);
 
65
                        }
 
66
                }
 
67
#endif
 
68
        }
 
69
 
 
70
        void Init()
 
71
        {
 
72
                self = dlopen(NULL, RTLD_LAZY);
 
73
 
 
74
                LoadFunction("glUnmapBuffer", (void**)&glUnmapBuffer);
 
75
 
 
76
                if (DriverDetails::HasBug(DriverDetails::BUG_ISTEGRA))
 
77
                {
 
78
                        LoadFunction("glBeginQueryEXT", (void**)&glBeginQuery);
 
79
                        LoadFunction("glEndQueryEXT", (void**)&glEndQuery);
 
80
                        LoadFunction("glGetQueryObjectuivEXT", (void**)&glGetQueryObjectuiv);
 
81
                        LoadFunction("glDeleteQueriesEXT", (void**)&glDeleteQueries);
 
82
                        LoadFunction("glGenQueriesEXT", (void**)&glGenQueries);
 
83
 
 
84
                        LoadFunction("glMapBufferRangeNV", (void**)&glMapBufferRange);
 
85
                        LoadFunction("glBindBufferRangeNV", (void**)&glBindBufferRange);
 
86
                        LoadFunction("glBlitFramebufferNV", (void**)&glBlitFramebuffer);
 
87
 
 
88
                        LoadFunction("glGenVertexArraysOES", (void**)&glGenVertexArrays);
 
89
                        LoadFunction("glDeleteVertexArraysOES", (void**)&glDeleteVertexArrays);
 
90
                        LoadFunction("glBindVertexArrayOES", (void**)&glBindVertexArray);
 
91
 
 
92
                        LoadFunction("glRenderbufferStorageMultisampleNV", (void**)&glRenderbufferStorageMultisample);
 
93
 
 
94
                        LoadFunction("glGetUniformBlockIndexNV", (void**)&glGetUniformBlockIndex);
 
95
                        LoadFunction("glUniformBlockBindingNV", (void**)&glUniformBlockBinding);
 
96
                }
 
97
                else
 
98
                {
 
99
                        LoadFunction("glBeginQuery", (void**)&glBeginQuery);
 
100
                        LoadFunction("glEndQuery", (void**)&glEndQuery);
 
101
                        LoadFunction("glGetQueryObjectuiv", (void**)&glGetQueryObjectuiv);
 
102
                        LoadFunction("glDeleteQueries", (void**)&glDeleteQueries);
 
103
                        LoadFunction("glGenQueries", (void**)&glGenQueries);
 
104
 
 
105
                        LoadFunction("glMapBufferRange", (void**)&glMapBufferRange);
 
106
                        LoadFunction("glBindBufferRange", (void**)&glBindBufferRange);
 
107
                        LoadFunction("glBlitFramebuffer", (void**)&glBlitFramebuffer);
 
108
 
 
109
                        LoadFunction("glGenVertexArrays", (void**)&glGenVertexArrays);
 
110
                        LoadFunction("glDeleteVertexArrays", (void**)&glDeleteVertexArrays);
 
111
                        LoadFunction("glBindVertexArray", (void**)&glBindVertexArray);
 
112
 
 
113
                        LoadFunction("glClientWaitSync", (void**)&glClientWaitSync);
 
114
                        LoadFunction("glDeleteSync", (void**)&glDeleteSync);
 
115
                        LoadFunction("glFenceSync", (void**)&glFenceSync);
 
116
 
 
117
                        LoadFunction("glSamplerParameterf", (void**)&glSamplerParameterf);
 
118
                        LoadFunction("glSamplerParameteri", (void**)&glSamplerParameteri);
 
119
                        LoadFunction("glSamplerParameterfv", (void**)&glSamplerParameterfv);
 
120
                        LoadFunction("glBindSampler", (void**)&glBindSampler);
 
121
                        LoadFunction("glDeleteSamplers", (void**)&glDeleteSamplers);
 
122
                        LoadFunction("glGenSamplers", (void**)&glGenSamplers);
 
123
                              
 
124
                        LoadFunction("glGetProgramBinary", (void**)&glGetProgramBinary);
 
125
                        LoadFunction("glProgramBinary", (void**)&glProgramBinary);
 
126
                        LoadFunction("glProgramParameteri", (void**)&glProgramParameteri);
 
127
                        
 
128
                        LoadFunction("glDrawRangeElements", (void**)&glDrawRangeElements);
 
129
 
 
130
                        LoadFunction("glRenderbufferStorageMultisample", (void**)&glRenderbufferStorageMultisample);
 
131
 
 
132
                        LoadFunction("glGetUniformBlockIndex", (void**)&glGetUniformBlockIndex);
 
133
                        LoadFunction("glUniformBlockBinding", (void**)&glUniformBlockBinding);
 
134
 
 
135
                }
 
136
                dlclose(self);
 
137
        }
 
138
}