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

Side by Side Diff: tools/gpu/gl/glx/CreatePlatformGLTestContext_glx.cpp

Issue 2147513002: Fix context creation problems in dm (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: add comment about static Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "gl/GLTestContext.h" 8 #include "gl/GLTestContext.h"
9 9
10 #include <X11/Xlib.h> 10 #include <X11/Xlib.h>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 177 }
178 } else { 178 } else {
179 //SkDebugf("Creating context.\n"); 179 //SkDebugf("Creating context.\n");
180 PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = 180 PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB =
181 (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddressARB((GrGLubyte* )"glXCreateContextAttribsARB"); 181 (PFNGLXCREATECONTEXTATTRIBSARBPROC) glXGetProcAddressARB((GrGLubyte* )"glXCreateContextAttribsARB");
182 182
183 if (kGLES_GrGLStandard == forcedGpuAPI) { 183 if (kGLES_GrGLStandard == forcedGpuAPI) {
184 if (gluCheckExtension( 184 if (gluCheckExtension(
185 reinterpret_cast<const GLubyte*>("GLX_EXT_create_context_es2 _profile"), 185 reinterpret_cast<const GLubyte*>("GLX_EXT_create_context_es2 _profile"),
186 reinterpret_cast<const GLubyte*>(glxExts))) { 186 reinterpret_cast<const GLubyte*>(glxExts))) {
187 static const int context_attribs_gles[] = { 187 const int context_attribs_gles[] = {
188 GLX_CONTEXT_MAJOR_VERSION_ARB, 3, 188 GLX_CONTEXT_MAJOR_VERSION_ARB, 2,
189 GLX_CONTEXT_MINOR_VERSION_ARB, 0, 189 GLX_CONTEXT_MINOR_VERSION_ARB, 0,
190 GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EX T, 190 GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_ES2_PROFILE_BIT_EX T,
191 None 191 None
192 }; 192 };
193 fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShar eContext, True, 193 fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShar eContext, True,
194 context_attribs_gles); 194 context_attribs_gles);
195 } 195 }
196 } else { 196 } else {
197 // Well, unfortunately GLX will not just give us the highest context so instead we have 197 // Well, unfortunately GLX will not just give us the highest context so instead we have
198 // to do this nastiness 198 // to do this nastiness
199 for (i = NUM_GL_VERSIONS - 2; i > 0 ; i--) { 199 for (i = NUM_GL_VERSIONS - 2; i > 0 ; i--) {
200 /* don't bother below GL 3.0 */ 200 /* don't bother below GL 3.0 */
201 if (gl_versions[i].major == 3 && gl_versions[i].minor == 0) { 201 if (gl_versions[i].major < 3) {
202 break; 202 break;
203 } 203 }
204 // On Nvidia GPUs, to use Nv Path rendering we need a compatibil ity profile for the 204 // On Nvidia GPUs, to use Nv Path rendering we need a compatibil ity profile for the
205 // time being. 205 // time being.
206 // TODO when Nvidia implements NVPR on Core profiles, we should start requesting 206 // TODO when Nvidia implements NVPR on Core profiles, we should start requesting
207 // core here 207 // core here
208 static const int context_attribs_gl[] = { 208 // Warning: This array should not be set to static. The
209 // glXCreateContextAttribsARB call writes to it upon failure and
210 // the next call would fail too.
211 const int context_attribs_gl[] = {
209 GLX_CONTEXT_MAJOR_VERSION_ARB, gl_versions[i].major, 212 GLX_CONTEXT_MAJOR_VERSION_ARB, gl_versions[i].major,
210 GLX_CONTEXT_MINOR_VERSION_ARB, gl_versions[i].minor, 213 GLX_CONTEXT_MINOR_VERSION_ARB, gl_versions[i].minor,
211 GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PR OFILE_BIT_ARB, 214 GLX_CONTEXT_PROFILE_MASK_ARB, GLX_CONTEXT_COMPATIBILITY_PR OFILE_BIT_ARB,
212 None 215 None
213 }; 216 };
214 fContext = 217 fContext =
215 glXCreateContextAttribsARB(fDisplay, bestFbc, glxShareCo ntext, True, 218 glXCreateContextAttribsARB(fDisplay, bestFbc, glxShareCo ntext, True,
216 context_attribs_gl); 219 context_attribs_gl);
217 220
218 // Sync to ensure any errors generated are processed. 221 // Sync to ensure any errors generated are processed.
219 XSync(fDisplay, False); 222 XSync(fDisplay, False);
220 223
221 if (!ctxErrorOccurred && fContext) { 224 if (!ctxErrorOccurred && fContext) {
222 break; 225 break;
223 } 226 }
224 // try again 227 // try again
225 ctxErrorOccurred = false; 228 ctxErrorOccurred = false;
226 } 229 }
227 230
228 // Couldn't create GL 3.0 context. 231 // Couldn't create GL 3.0 context.
229 // Fall back to old-style 2.x context. 232 // Fall back to old-style 2.x context.
230 // When a context version below 3.0 is requested, 233 // When a context version below 3.0 is requested,
231 // implementations will return the newest context version 234 // implementations will return the newest context version
232 // compatible with OpenGL versions less than version 3.0. 235 // compatible with OpenGL versions less than version 3.0.
233 if (ctxErrorOccurred || !fContext) { 236 if (ctxErrorOccurred || !fContext) {
234 static const int context_attribs_gl_fallback[] = { 237 const int context_attribs_gl_fallback[] = {
235 GLX_CONTEXT_MAJOR_VERSION_ARB, 1, 238 GLX_CONTEXT_MAJOR_VERSION_ARB, 1,
236 GLX_CONTEXT_MINOR_VERSION_ARB, 0, 239 GLX_CONTEXT_MINOR_VERSION_ARB, 0,
237 None 240 None
238 }; 241 };
239 242
240 ctxErrorOccurred = false; 243 ctxErrorOccurred = false;
241 244
242 fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShar eContext, True, 245 fContext = glXCreateContextAttribsARB(fDisplay, bestFbc, glxShar eContext, True,
243 context_attribs_gl_fallbac k); 246 context_attribs_gl_fallbac k);
244 } 247 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 GLTestContext *shareContext) { 341 GLTestContext *shareContext) {
339 GLXGLTestContext *glxShareContext = reinterpret_cast<GLXGLTestContext *>(sha reContext); 342 GLXGLTestContext *glxShareContext = reinterpret_cast<GLXGLTestContext *>(sha reContext);
340 GLXGLTestContext *ctx = new GLXGLTestContext(forcedGpuAPI, glxShareContext); 343 GLXGLTestContext *ctx = new GLXGLTestContext(forcedGpuAPI, glxShareContext);
341 if (!ctx->isValid()) { 344 if (!ctx->isValid()) {
342 delete ctx; 345 delete ctx;
343 return nullptr; 346 return nullptr;
344 } 347 }
345 return ctx; 348 return ctx;
346 } 349 }
347 } // namespace sk_gpu_test 350 } // namespace sk_gpu_test
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698