Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: src/gpu/gl/mesa/GrGLCreateMesaInterface.cpp

Issue 12328111: Use glGetStringi to get extensions when available. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9 #include "gl/GrGLExtensions.h"
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
11 #include "../GrGLUtil.h" 11 #include "../GrGLUtil.h"
12 12
13 #define GL_GLEXT_PROTOTYPES 13 #define GL_GLEXT_PROTOTYPES
14 #include "osmesa_wrapper.h" 14 #include "osmesa_wrapper.h"
15 15
16 #define GR_GL_GET_PROC(F) interface->f ## F = (GrGL ## F ## Proc) \ 16 #define GR_GL_GET_PROC(F) interface->f ## F = (GrGL ## F ## Proc) \
17 OSMesaGetProcAddress("gl" #F); 17 OSMesaGetProcAddress("gl" #F);
18 #define GR_GL_GET_PROC_SUFFIX(F, S) interface->f ## F = (GrGL ## F ## Proc) \ 18 #define GR_GL_GET_PROC_SUFFIX(F, S) interface->f ## F = (GrGL ## F ## Proc) \
19 OSMesaGetProcAddress("gl" #F #S); 19 OSMesaGetProcAddress("gl" #F #S);
20 20
21 // We use OSMesaGetProcAddress for every gl function to avoid accidentally using 21 // We use OSMesaGetProcAddress for every gl function to avoid accidentally using
22 // non-Mesa gl functions. 22 // non-Mesa gl functions.
23 23
24 const GrGLInterface* GrGLCreateMesaInterface() { 24 const GrGLInterface* GrGLCreateMesaInterface() {
25 if (NULL != OSMesaGetCurrentContext()) { 25 if (NULL != OSMesaGetCurrentContext()) {
26 GrGLGetStringProc getString = (GrGLGetStringProc) OSMesaGetProcAddress(" glGetString"); 26
27 GrGLGetStringProc getString =
28 (GrGLGetStringProc) OSMesaGetProcAddress("glGetString");
29 GrGLGetStringiProc glGetStringi =
30 (GrGLGetStringiProc) OSMesaGetProcAddress("glGetStringi");
31 GrGLGetIntegervProc glGetIntegerv =
32 (GrGLGetIntegervProc) OSMesaGetProcAddress("glGetIntegerv");
33
34 GrGLExtensions extensions;
35 if (!extensions.init(kDesktop_GrGLBinding, glGetString, glGetStringi, gl GetIntegerv)) {
36 return NULL;
37 }
38
27 const char* versionString = (const char*) getString(GL_VERSION); 39 const char* versionString = (const char*) getString(GL_VERSION);
28 const char* extString = (const char*) getString(GL_EXTENSIONS);
29 GrGLVersion glVer = GrGLGetVersionFromString(versionString); 40 GrGLVersion glVer = GrGLGetVersionFromString(versionString);
30 41
31 if (glVer < GR_GL_VER(1,5)) { 42 if (glVer < GR_GL_VER(1,5)) {
32 // We must have array and element_array buffer objects. 43 // We must have array and element_array buffer objects.
33 return NULL; 44 return NULL;
34 } 45 }
35 GrGLInterface* interface = new GrGLInterface(); 46 GrGLInterface* interface = new GrGLInterface();
36 47
37 GR_GL_GET_PROC(ActiveTexture); 48 GR_GL_GET_PROC(ActiveTexture);
38 GR_GL_GET_PROC(BeginQuery); 49 GR_GL_GET_PROC(BeginQuery);
39 GR_GL_GET_PROC(AttachShader); 50 GR_GL_GET_PROC(AttachShader);
40 GR_GL_GET_PROC(BindAttribLocation); 51 GR_GL_GET_PROC(BindAttribLocation);
41 GR_GL_GET_PROC(BindBuffer); 52 GR_GL_GET_PROC(BindBuffer);
42 GR_GL_GET_PROC(BindFragDataLocation); 53 GR_GL_GET_PROC(BindFragDataLocation);
43 GR_GL_GET_PROC(BindTexture); 54 GR_GL_GET_PROC(BindTexture);
44 GR_GL_GET_PROC(BlendFunc); 55 GR_GL_GET_PROC(BlendFunc);
45 56
46 if (glVer >= GR_GL_VER(1,4) || 57 if (glVer >= GR_GL_VER(1,4) ||
47 GrGLHasExtensionFromString("GL_ARB_imaging", extString) || 58 extensions.has("GL_ARB_imaging") ||
48 GrGLHasExtensionFromString("GL_EXT_blend_color", extString)) { 59 extensions.has("GL_EXT_blend_color")) {
49 GR_GL_GET_PROC(BlendColor); 60 GR_GL_GET_PROC(BlendColor);
50 } 61 }
51 62
52 GR_GL_GET_PROC(BufferData); 63 GR_GL_GET_PROC(BufferData);
53 GR_GL_GET_PROC(BufferSubData); 64 GR_GL_GET_PROC(BufferSubData);
54 GR_GL_GET_PROC(Clear); 65 GR_GL_GET_PROC(Clear);
55 GR_GL_GET_PROC(ClearColor); 66 GR_GL_GET_PROC(ClearColor);
56 GR_GL_GET_PROC(ClearStencil); 67 GR_GL_GET_PROC(ClearStencil);
57 GR_GL_GET_PROC(ColorMask); 68 GR_GL_GET_PROC(ColorMask);
58 GR_GL_GET_PROC(CompileShader); 69 GR_GL_GET_PROC(CompileShader);
(...skipping 19 matching lines...) Expand all
78 GR_GL_GET_PROC(Finish); 89 GR_GL_GET_PROC(Finish);
79 GR_GL_GET_PROC(Flush); 90 GR_GL_GET_PROC(Flush);
80 GR_GL_GET_PROC(FrontFace); 91 GR_GL_GET_PROC(FrontFace);
81 GR_GL_GET_PROC(GenBuffers); 92 GR_GL_GET_PROC(GenBuffers);
82 GR_GL_GET_PROC(GenQueries); 93 GR_GL_GET_PROC(GenQueries);
83 GR_GL_GET_PROC(GetBufferParameteriv); 94 GR_GL_GET_PROC(GetBufferParameteriv);
84 GR_GL_GET_PROC(GetError); 95 GR_GL_GET_PROC(GetError);
85 GR_GL_GET_PROC(GetIntegerv); 96 GR_GL_GET_PROC(GetIntegerv);
86 GR_GL_GET_PROC(GetProgramInfoLog); 97 GR_GL_GET_PROC(GetProgramInfoLog);
87 GR_GL_GET_PROC(GetProgramiv); 98 GR_GL_GET_PROC(GetProgramiv);
88 if (glVer >= GR_GL_VER(3,3) || 99 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
89 GrGLHasExtensionFromString("GL_ARB_timer_query", extString)) {
90 GR_GL_GET_PROC(GetQueryObjecti64v); 100 GR_GL_GET_PROC(GetQueryObjecti64v);
91 GR_GL_GET_PROC(GetQueryObjectui64v) 101 GR_GL_GET_PROC(GetQueryObjectui64v)
92 GR_GL_GET_PROC(QueryCounter); 102 GR_GL_GET_PROC(QueryCounter);
93 } else if (GrGLHasExtensionFromString("GL_EXT_timer_query", extString)) { 103 } else if (extensions.has("GL_EXT_timer_query")) {
94 GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT); 104 GR_GL_GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
95 GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT); 105 GR_GL_GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
96 } 106 }
97 GR_GL_GET_PROC(GetQueryObjectiv); 107 GR_GL_GET_PROC(GetQueryObjectiv);
98 GR_GL_GET_PROC(GetQueryObjectuiv); 108 GR_GL_GET_PROC(GetQueryObjectuiv);
99 GR_GL_GET_PROC(GetQueryiv); 109 GR_GL_GET_PROC(GetQueryiv);
100 GR_GL_GET_PROC(GetShaderInfoLog); 110 GR_GL_GET_PROC(GetShaderInfoLog);
101 GR_GL_GET_PROC(GetShaderiv); 111 GR_GL_GET_PROC(GetShaderiv);
102 GR_GL_GET_PROC(GetString); 112 GR_GL_GET_PROC(GetString);
113 GR_GL_GET_PROC(GetStringi);
103 GR_GL_GET_PROC(GetTexLevelParameteriv); 114 GR_GL_GET_PROC(GetTexLevelParameteriv);
104 GR_GL_GET_PROC(GenTextures); 115 GR_GL_GET_PROC(GenTextures);
105 GR_GL_GET_PROC(GetUniformLocation); 116 GR_GL_GET_PROC(GetUniformLocation);
106 GR_GL_GET_PROC(LineWidth); 117 GR_GL_GET_PROC(LineWidth);
107 GR_GL_GET_PROC(LinkProgram); 118 GR_GL_GET_PROC(LinkProgram);
108 GR_GL_GET_PROC(MapBuffer); 119 GR_GL_GET_PROC(MapBuffer);
109 GR_GL_GET_PROC(PixelStorei); 120 GR_GL_GET_PROC(PixelStorei);
110 GR_GL_GET_PROC(ReadBuffer); 121 GR_GL_GET_PROC(ReadBuffer);
111 GR_GL_GET_PROC(ReadPixels); 122 GR_GL_GET_PROC(ReadPixels);
112 GR_GL_GET_PROC(Scissor); 123 GR_GL_GET_PROC(Scissor);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 GR_GL_GET_PROC(UniformMatrix3fv); 156 GR_GL_GET_PROC(UniformMatrix3fv);
146 GR_GL_GET_PROC(UniformMatrix4fv); 157 GR_GL_GET_PROC(UniformMatrix4fv);
147 GR_GL_GET_PROC(UnmapBuffer); 158 GR_GL_GET_PROC(UnmapBuffer);
148 GR_GL_GET_PROC(UseProgram); 159 GR_GL_GET_PROC(UseProgram);
149 GR_GL_GET_PROC(VertexAttrib4fv); 160 GR_GL_GET_PROC(VertexAttrib4fv);
150 GR_GL_GET_PROC(VertexAttribPointer); 161 GR_GL_GET_PROC(VertexAttribPointer);
151 GR_GL_GET_PROC(Viewport); 162 GR_GL_GET_PROC(Viewport);
152 163
153 // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since 164 // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
154 // GL_ARB_framebuffer_object doesn't use ARB suffix.) 165 // GL_ARB_framebuffer_object doesn't use ARB suffix.)
155 if (glVer >= GR_GL_VER(3,0) || 166 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object ")) {
156 GrGLHasExtensionFromString("GL_ARB_framebuffer_object",
157 extString)) {
158 GR_GL_GET_PROC(GenFramebuffers); 167 GR_GL_GET_PROC(GenFramebuffers);
159 GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv); 168 GR_GL_GET_PROC(GetFramebufferAttachmentParameteriv);
160 GR_GL_GET_PROC(GetRenderbufferParameteriv); 169 GR_GL_GET_PROC(GetRenderbufferParameteriv);
161 GR_GL_GET_PROC(BindFramebuffer); 170 GR_GL_GET_PROC(BindFramebuffer);
162 GR_GL_GET_PROC(FramebufferTexture2D); 171 GR_GL_GET_PROC(FramebufferTexture2D);
163 GR_GL_GET_PROC(CheckFramebufferStatus); 172 GR_GL_GET_PROC(CheckFramebufferStatus);
164 GR_GL_GET_PROC(DeleteFramebuffers); 173 GR_GL_GET_PROC(DeleteFramebuffers);
165 GR_GL_GET_PROC(RenderbufferStorage); 174 GR_GL_GET_PROC(RenderbufferStorage);
166 GR_GL_GET_PROC(GenRenderbuffers); 175 GR_GL_GET_PROC(GenRenderbuffers);
167 GR_GL_GET_PROC(DeleteRenderbuffers); 176 GR_GL_GET_PROC(DeleteRenderbuffers);
168 GR_GL_GET_PROC(FramebufferRenderbuffer); 177 GR_GL_GET_PROC(FramebufferRenderbuffer);
169 GR_GL_GET_PROC(BindRenderbuffer); 178 GR_GL_GET_PROC(BindRenderbuffer);
170 GR_GL_GET_PROC(RenderbufferStorageMultisample); 179 GR_GL_GET_PROC(RenderbufferStorageMultisample);
171 GR_GL_GET_PROC(BlitFramebuffer); 180 GR_GL_GET_PROC(BlitFramebuffer);
172 } else if (GrGLHasExtensionFromString("GL_EXT_framebuffer_object", 181 } else if (extensions.has("GL_EXT_framebuffer_object")) {
173 extString)) {
174 GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT); 182 GR_GL_GET_PROC_SUFFIX(GenFramebuffers, EXT);
175 GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT); 183 GR_GL_GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
176 GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT); 184 GR_GL_GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
177 GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT); 185 GR_GL_GET_PROC_SUFFIX(BindFramebuffer, EXT);
178 GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT); 186 GR_GL_GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
179 GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT); 187 GR_GL_GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
180 GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT); 188 GR_GL_GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
181 GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT); 189 GR_GL_GET_PROC_SUFFIX(RenderbufferStorage, EXT);
182 GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT); 190 GR_GL_GET_PROC_SUFFIX(GenRenderbuffers, EXT);
183 GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT); 191 GR_GL_GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
184 GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT); 192 GR_GL_GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
185 GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT); 193 GR_GL_GET_PROC_SUFFIX(BindRenderbuffer, EXT);
186 if (GrGLHasExtensionFromString("GL_EXT_framebuffer_multisample", 194 if (extensions.has("GL_EXT_framebuffer_multisample")) {
187 extString)) {
188 GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT); 195 GR_GL_GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
189 } 196 }
190 if (GrGLHasExtensionFromString("GL_EXT_framebuffer_blit", 197 if (extensions.has("GL_EXT_framebuffer_blit")) {
191 extString)) {
192 GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT); 198 GR_GL_GET_PROC_SUFFIX(BlitFramebuffer, EXT);
193 } 199 }
194 } else { 200 } else {
195 // we must have FBOs 201 // we must have FBOs
196 delete interface; 202 delete interface;
197 return NULL; 203 return NULL;
198 } 204 }
199 GR_GL_GET_PROC(BindFragDataLocationIndexed); 205 GR_GL_GET_PROC(BindFragDataLocationIndexed);
200 interface->fBindingsExported = kDesktop_GrGLBinding; 206 interface->fBindingsExported = kDesktop_GrGLBinding;
201 return interface; 207 return interface;
202 } else { 208 } else {
203 return NULL; 209 return NULL;
204 } 210 }
205 } 211 }
OLDNEW
« no previous file with comments | « src/gpu/gl/mac/SkNativeGLContext_mac.cpp ('k') | src/gpu/gl/unix/GrGLCreateNativeInterface_unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698