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

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

Issue 254713006: Common GrGLInterface OpenGL setup function. (Closed) Base URL: https://skia.googlesource.com/skia.git@grgl
Patch Set: Address additional comment Created 6 years, 7 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
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 #include "gl/GrGLExtensions.h" 9 #include "gl/GrGLAssembleInterface.h"
10 #include "gl/GrGLInterface.h"
11 #include "../GrGLUtil.h" 10 #include "../GrGLUtil.h"
12 11
13 #define GL_GLEXT_PROTOTYPES
14 #include "osmesa_wrapper.h" 12 #include "osmesa_wrapper.h"
15 13
16 #define GET_PROC(F) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \ 14 static GrGLFuncPtr osmesa_get(void* ctx, const char name[]) {
17 OSMesaGetProcAddress("gl" #F); 15 SkASSERT(NULL == ctx);
18 #define GET_PROC_SUFFIX(F, S) interface->fFunctions.f ## F = (GrGL ## F ## Proc) \ 16 SkASSERT(NULL != OSMesaGetCurrentContext());
19 OSMesaGetProcAddress("gl" #F #S); 17 return OSMesaGetProcAddress(name);
20 18 }
21 // We use OSMesaGetProcAddress for every gl function to avoid accidentally using
22 // non-Mesa gl functions.
23 19
24 const GrGLInterface* GrGLCreateMesaInterface() { 20 const GrGLInterface* GrGLCreateMesaInterface() {
25 if (NULL == OSMesaGetCurrentContext()) { 21 if (NULL == OSMesaGetCurrentContext()) {
26 return NULL; 22 return NULL;
27 } 23 }
28 24 return GrGLAssembleGLInterface(NULL, osmesa_get);
29 GrGLGetStringProc getString = (GrGLGetStringProc) OSMesaGetProcAddress("glGe tString");
30 GrGLGetStringiProc getStringi = (GrGLGetStringiProc) OSMesaGetProcAddress("g lGetStringi");
31 GrGLGetIntegervProc getIntegerv =
32 (GrGLGetIntegervProc) OSMesaGetProcAddress("glGetIntegerv");
33
34 GrGLExtensions extensions;
35 if (!extensions.init(kGL_GrGLStandard, getString, getStringi, getIntegerv)) {
36 return NULL;
37 }
38
39 const char* versionString = (const char*) getString(GL_VERSION);
40 GrGLVersion glVer = GrGLGetVersionFromString(versionString);
41
42 if (glVer < GR_GL_VER(1,5)) {
43 // We must have array and element_array buffer objects.
44 return NULL;
45 }
46 GrGLInterface* interface = SkNEW(GrGLInterface());
47
48 GET_PROC(ActiveTexture);
49 GET_PROC(BeginQuery);
50 GET_PROC(AttachShader);
51 GET_PROC(BindAttribLocation);
52 GET_PROC(BindBuffer);
53 GET_PROC(BindFragDataLocation);
54 GET_PROC(BindTexture);
55 GET_PROC(BlendFunc);
56
57 if (glVer >= GR_GL_VER(1,4) ||
58 extensions.has("GL_ARB_imaging") ||
59 extensions.has("GL_EXT_blend_color")) {
60 GET_PROC(BlendColor);
61 }
62
63 GET_PROC(BufferData);
64 GET_PROC(BufferSubData);
65 GET_PROC(Clear);
66 GET_PROC(ClearColor);
67 GET_PROC(ClearStencil);
68 GET_PROC(ColorMask);
69 GET_PROC(CompileShader);
70 GET_PROC(CompressedTexImage2D);
71 GET_PROC(CopyTexSubImage2D);
72 GET_PROC(CreateProgram);
73 GET_PROC(CreateShader);
74 GET_PROC(CullFace);
75 GET_PROC(DeleteBuffers);
76 GET_PROC(DeleteProgram);
77 GET_PROC(DeleteQueries);
78 GET_PROC(DeleteShader);
79 GET_PROC(DeleteTextures);
80 GET_PROC(DepthMask);
81 GET_PROC(Disable);
82 GET_PROC(DisableVertexAttribArray);
83 GET_PROC(DrawArrays);
84 GET_PROC(DrawBuffer);
85 GET_PROC(DrawBuffers);
86 GET_PROC(DrawElements);
87 GET_PROC(Enable);
88 GET_PROC(EnableVertexAttribArray);
89 GET_PROC(EndQuery);
90 GET_PROC(Finish);
91 GET_PROC(Flush);
92 GET_PROC(FrontFace);
93 GET_PROC(GenBuffers);
94 GET_PROC(GenerateMipmap);
95 GET_PROC(GenQueries);
96 GET_PROC(GetBufferParameteriv);
97 GET_PROC(GetError);
98 GET_PROC(GetIntegerv);
99 GET_PROC(GetProgramInfoLog);
100 GET_PROC(GetProgramiv);
101 if (glVer >= GR_GL_VER(3,3) || extensions.has("GL_ARB_timer_query")) {
102 GET_PROC(GetQueryObjecti64v);
103 GET_PROC(GetQueryObjectui64v)
104 GET_PROC(QueryCounter);
105 } else if (extensions.has("GL_EXT_timer_query")) {
106 GET_PROC_SUFFIX(GetQueryObjecti64v, EXT);
107 GET_PROC_SUFFIX(GetQueryObjectui64v, EXT);
108 }
109 GET_PROC(GetQueryObjectiv);
110 GET_PROC(GetQueryObjectuiv);
111 GET_PROC(GetQueryiv);
112 GET_PROC(GetShaderInfoLog);
113 GET_PROC(GetShaderiv);
114 GET_PROC(GetString);
115 GET_PROC(GetStringi);
116 GET_PROC(GetTexLevelParameteriv);
117 GET_PROC(GenTextures);
118 GET_PROC(GetUniformLocation);
119 GET_PROC(LineWidth);
120 GET_PROC(LinkProgram);
121 GET_PROC(MapBuffer);
122 if (extensions.has("GL_EXT_direct_state_access")) {
123 GET_PROC_SUFFIX(MatrixLoadf, EXT);
124 GET_PROC_SUFFIX(MatrixLoadIdentity, EXT);
125 }
126 GET_PROC(PixelStorei);
127 GET_PROC(ReadBuffer);
128 GET_PROC(ReadPixels);
129 GET_PROC(Scissor);
130 GET_PROC(ShaderSource);
131 GET_PROC(StencilFunc);
132 GET_PROC(StencilFuncSeparate);
133 GET_PROC(StencilMask);
134 GET_PROC(StencilMaskSeparate);
135 GET_PROC(StencilOp);
136 GET_PROC(StencilOpSeparate);
137 GET_PROC(TexImage2D)
138 GET_PROC(TexParameteri);
139 GET_PROC(TexParameteriv);
140 GET_PROC(TexStorage2D);
141 if (NULL == interface->fFunctions.fTexStorage2D) {
142 GET_PROC_SUFFIX(TexStorage2D, EXT);
143 }
144 GET_PROC(TexSubImage2D);
145 GET_PROC(Uniform1f);
146 GET_PROC(Uniform1i);
147 GET_PROC(Uniform1fv);
148 GET_PROC(Uniform1iv);
149 GET_PROC(Uniform2f);
150 GET_PROC(Uniform2i);
151 GET_PROC(Uniform2fv);
152 GET_PROC(Uniform2iv);
153 GET_PROC(Uniform3f);
154 GET_PROC(Uniform3i);
155 GET_PROC(Uniform3fv);
156 GET_PROC(Uniform3iv);
157 GET_PROC(Uniform4f);
158 GET_PROC(Uniform4i);
159 GET_PROC(Uniform4fv);
160 GET_PROC(Uniform4iv);
161 GET_PROC(UniformMatrix2fv);
162 GET_PROC(UniformMatrix3fv);
163 GET_PROC(UniformMatrix4fv);
164 GET_PROC(UnmapBuffer);
165 GET_PROC(UseProgram);
166 GET_PROC(VertexAttrib4fv);
167 GET_PROC(VertexAttribPointer);
168 GET_PROC(Viewport);
169
170 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_vertex_array_object")) {
171 // no ARB suffix for GL_ARB_vertex_array_object
172 GET_PROC(BindVertexArray);
173 GET_PROC(DeleteVertexArrays);
174 GET_PROC(GenVertexArrays);
175 }
176
177 // First look for GL3.0 FBO or GL_ARB_framebuffer_object (same since
178 // GL_ARB_framebuffer_object doesn't use ARB suffix.)
179 if (glVer >= GR_GL_VER(3,0) || extensions.has("GL_ARB_framebuffer_object")) {
180 GET_PROC(GenFramebuffers);
181 GET_PROC(GetFramebufferAttachmentParameteriv);
182 GET_PROC(GetRenderbufferParameteriv);
183 GET_PROC(BindFramebuffer);
184 GET_PROC(FramebufferTexture2D);
185 GET_PROC(CheckFramebufferStatus);
186 GET_PROC(DeleteFramebuffers);
187 GET_PROC(RenderbufferStorage);
188 GET_PROC(GenRenderbuffers);
189 GET_PROC(DeleteRenderbuffers);
190 GET_PROC(FramebufferRenderbuffer);
191 GET_PROC(BindRenderbuffer);
192 GET_PROC(RenderbufferStorageMultisample);
193 GET_PROC(BlitFramebuffer);
194 } else if (extensions.has("GL_EXT_framebuffer_object")) {
195 GET_PROC_SUFFIX(GenFramebuffers, EXT);
196 GET_PROC_SUFFIX(GetFramebufferAttachmentParameteriv, EXT);
197 GET_PROC_SUFFIX(GetRenderbufferParameteriv, EXT);
198 GET_PROC_SUFFIX(BindFramebuffer, EXT);
199 GET_PROC_SUFFIX(FramebufferTexture2D, EXT);
200 GET_PROC_SUFFIX(CheckFramebufferStatus, EXT);
201 GET_PROC_SUFFIX(DeleteFramebuffers, EXT);
202 GET_PROC_SUFFIX(RenderbufferStorage, EXT);
203 GET_PROC_SUFFIX(GenRenderbuffers, EXT);
204 GET_PROC_SUFFIX(DeleteRenderbuffers, EXT);
205 GET_PROC_SUFFIX(FramebufferRenderbuffer, EXT);
206 GET_PROC_SUFFIX(BindRenderbuffer, EXT);
207 if (extensions.has("GL_EXT_framebuffer_multisample")) {
208 GET_PROC_SUFFIX(RenderbufferStorageMultisample, EXT);
209 }
210 if (extensions.has("GL_EXT_framebuffer_blit")) {
211 GET_PROC_SUFFIX(BlitFramebuffer, EXT);
212 }
213 } else {
214 // we must have FBOs
215 delete interface;
216 return NULL;
217 }
218 GET_PROC(BindFragDataLocationIndexed);
219
220 if (extensions.has("GL_EXT_debug_marker")) {
221 GET_PROC_SUFFIX(InsertEventMarker, EXT);
222 GET_PROC_SUFFIX(PopGroupMarker, EXT);
223 GET_PROC_SUFFIX(PushGroupMarker, EXT);
224 }
225
226 if (glVer >= GR_GL_VER(4,3) || extensions.has("GL_ARB_invalidate_subdata")) {
227 GET_PROC(InvalidateBufferData);
228 GET_PROC(InvalidateBufferSubData);
229 GET_PROC(InvalidateFramebuffer);
230 GET_PROC(InvalidateSubFramebuffer);
231 GET_PROC(InvalidateTexImage);
232 GET_PROC(InvalidateTexSubImage);
233 }
234
235 interface->fStandard = kGL_GrGLStandard;
236 interface->fExtensions.swap(&extensions);
237
238 return interface;
239 } 25 }
OLDNEW
« no previous file with comments | « src/gpu/gl/mac/GrGLCreateNativeInterface_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