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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 978593003: Distinguish ES2/ES3 contexts in GPU command buffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webgl2
Patch Set: rebase Created 5 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 2423 matching lines...) Expand 10 before | Expand all | Expand 10 after
2434 const scoped_refptr<gfx::GLSurface>& surface, 2434 const scoped_refptr<gfx::GLSurface>& surface,
2435 const scoped_refptr<gfx::GLContext>& context, 2435 const scoped_refptr<gfx::GLContext>& context,
2436 bool offscreen, 2436 bool offscreen,
2437 const gfx::Size& size, 2437 const gfx::Size& size,
2438 const DisallowedFeatures& disallowed_features, 2438 const DisallowedFeatures& disallowed_features,
2439 const std::vector<int32>& attribs) { 2439 const std::vector<int32>& attribs) {
2440 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); 2440 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize");
2441 DCHECK(context->IsCurrent(surface.get())); 2441 DCHECK(context->IsCurrent(surface.get()));
2442 DCHECK(!context_.get()); 2442 DCHECK(!context_.get());
2443 2443
2444 ContextCreationAttribHelper attrib_parser;
2445 if (!attrib_parser.Parse(attribs))
2446 return false;
2447
2444 surfaceless_ = surface->IsSurfaceless() && !offscreen; 2448 surfaceless_ = surface->IsSurfaceless() && !offscreen;
2445 2449
2446 set_initialized(); 2450 set_initialized();
2447 gpu_state_tracer_ = GPUStateTracer::Create(&state_); 2451 gpu_state_tracer_ = GPUStateTracer::Create(&state_);
2448 2452
2449 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2453 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2450 switches::kEnableGPUDebugging)) { 2454 switches::kEnableGPUDebugging)) {
2451 set_debug(true); 2455 set_debug(true);
2452 } 2456 }
2453 2457
2454 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2458 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2455 switches::kEnableGPUCommandLogging)) { 2459 switches::kEnableGPUCommandLogging)) {
2456 set_log_commands(true); 2460 set_log_commands(true);
2457 } 2461 }
2458 2462
2459 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 2463 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
2460 switches::kEnableUnsafeES3APIs)) { 2464 switches::kEnableUnsafeES3APIs) &&
2465 attrib_parser.es3_context_required) {
2466 // TODO(zmo): We need to implement capabilities check to ensure we can
2467 // actually create ES3 contexts.
2461 set_unsafe_es3_apis_enabled(true); 2468 set_unsafe_es3_apis_enabled(true);
2462 } 2469 }
2463 2470
2464 compile_shader_always_succeeds_ = 2471 compile_shader_always_succeeds_ =
2465 base::CommandLine::ForCurrentProcess()->HasSwitch( 2472 base::CommandLine::ForCurrentProcess()->HasSwitch(
2466 switches::kCompileShaderAlwaysSucceeds); 2473 switches::kCompileShaderAlwaysSucceeds);
2467 2474
2468 // Take ownership of the context and surface. The surface can be replaced with 2475 // Take ownership of the context and surface. The surface can be replaced with
2469 // SetSurface. 2476 // SetSurface.
2470 context_ = context; 2477 context_ = context;
2471 surface_ = surface; 2478 surface_ = surface;
2472 2479
2473 ContextCreationAttribHelper attrib_parser;
2474 if (!attrib_parser.Parse(attribs))
2475 return false;
2476
2477 // Create GPU Tracer for timing values. 2480 // Create GPU Tracer for timing values.
2478 gpu_tracer_.reset(new GPUTracer(this)); 2481 gpu_tracer_.reset(new GPUTracer(this));
2479 2482
2480 // Save the loseContextWhenOutOfMemory context creation attribute. 2483 // Save the loseContextWhenOutOfMemory context creation attribute.
2481 lose_context_when_out_of_memory_ = 2484 lose_context_when_out_of_memory_ =
2482 attrib_parser.lose_context_when_out_of_memory; 2485 attrib_parser.lose_context_when_out_of_memory;
2483 2486
2484 // If the failIfMajorPerformanceCaveat context creation attribute was true 2487 // If the failIfMajorPerformanceCaveat context creation attribute was true
2485 // and we are using a software renderer, fail. 2488 // and we are using a software renderer, fail.
2486 if (attrib_parser.fail_if_major_perf_caveat && 2489 if (attrib_parser.fail_if_major_perf_caveat &&
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 resources.EXT_draw_buffers = 2952 resources.EXT_draw_buffers =
2950 features().ext_draw_buffers ? 1 : 0; 2953 features().ext_draw_buffers ? 1 : 0;
2951 resources.EXT_frag_depth = 2954 resources.EXT_frag_depth =
2952 features().ext_frag_depth ? 1 : 0; 2955 features().ext_frag_depth ? 1 : 0;
2953 resources.EXT_shader_texture_lod = 2956 resources.EXT_shader_texture_lod =
2954 features().ext_shader_texture_lod ? 1 : 0; 2957 features().ext_shader_texture_lod ? 1 : 0;
2955 resources.NV_draw_buffers = 2958 resources.NV_draw_buffers =
2956 features().nv_draw_buffers ? 1 : 0; 2959 features().nv_draw_buffers ? 1 : 0;
2957 } 2960 }
2958 2961
2959 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC 2962 ShShaderSpec shader_spec;
2960 : SH_GLES2_SPEC; 2963 if (force_webgl_glsl_validation_) {
2961 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) 2964 shader_spec = unsafe_es3_apis_enabled() ? SH_WEBGL2_SPEC : SH_WEBGL_SPEC;
2965 } else {
2966 shader_spec = unsafe_es3_apis_enabled() ? SH_GLES3_SPEC : SH_GLES2_SPEC;
2967 }
2968
2969 if ((shader_spec == SH_WEBGL_SPEC || shader_spec == SH_WEBGL2_SPEC) &&
2970 features().enable_shader_name_hashing)
2962 resources.HashFunction = &CityHash64; 2971 resources.HashFunction = &CityHash64;
2963 else 2972 else
2964 resources.HashFunction = NULL; 2973 resources.HashFunction = NULL;
2965 ShaderTranslatorInterface::GlslImplementationType implementation_type = 2974 ShaderTranslatorInterface::GlslImplementationType implementation_type =
2966 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? 2975 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ?
2967 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; 2976 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl;
2968 int driver_bug_workarounds = 0; 2977 int driver_bug_workarounds = 0;
2969 if (workarounds().needs_glsl_built_in_function_emulation) 2978 if (workarounds().needs_glsl_built_in_function_emulation)
2970 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS; 2979 driver_bug_workarounds |= SH_EMULATE_BUILT_IN_FUNCTIONS;
2971 if (workarounds().init_gl_position_in_vertex_shader) 2980 if (workarounds().init_gl_position_in_vertex_shader)
(...skipping 9155 matching lines...) Expand 10 before | Expand all | Expand 10 after
12127 } 12136 }
12128 } 12137 }
12129 12138
12130 // Include the auto-generated part of this file. We split this because it means 12139 // Include the auto-generated part of this file. We split this because it means
12131 // we can easily edit the non-auto generated parts right here in this file 12140 // we can easily edit the non-auto generated parts right here in this file
12132 // instead of having to edit some template or the code generator. 12141 // instead of having to edit some template or the code generator.
12133 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 12142 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
12134 12143
12135 } // namespace gles2 12144 } // namespace gles2
12136 } // namespace gpu 12145 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/common/gles2_cmd_utils.cc ('k') | gpu/command_buffer/service/shader_translator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698