OLD | NEW |
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 2197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 | 2208 |
2209 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch( | 2209 compile_shader_always_succeeds_ = CommandLine::ForCurrentProcess()->HasSwitch( |
2210 switches::kCompileShaderAlwaysSucceeds); | 2210 switches::kCompileShaderAlwaysSucceeds); |
2211 | 2211 |
2212 | 2212 |
2213 // Take ownership of the context and surface. The surface can be replaced with | 2213 // Take ownership of the context and surface. The surface can be replaced with |
2214 // SetSurface. | 2214 // SetSurface. |
2215 context_ = context; | 2215 context_ = context; |
2216 surface_ = surface; | 2216 surface_ = surface; |
2217 | 2217 |
| 2218 ContextCreationAttribHelper attrib_parser; |
| 2219 if (!attrib_parser.Parse(attribs)) |
| 2220 return false; |
| 2221 |
| 2222 // If the failIfMajorPerformanceCaveat context creation attribute was true |
| 2223 // and we are using a software renderer, fail. |
| 2224 if (attrib_parser.fail_if_major_perf_caveat_ && |
| 2225 feature_info_->feature_flags().is_swiftshader) { |
| 2226 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
| 2227 Destroy(true); |
| 2228 return false; |
| 2229 } |
| 2230 |
2218 if (!group_->Initialize(this, disallowed_features)) { | 2231 if (!group_->Initialize(this, disallowed_features)) { |
2219 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " | 2232 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " |
2220 << "failed to initialize."; | 2233 << "failed to initialize."; |
2221 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. | 2234 group_ = NULL; // Must not destroy ContextGroup if it is not initialized. |
2222 Destroy(true); | 2235 Destroy(true); |
2223 return false; | 2236 return false; |
2224 } | 2237 } |
2225 CHECK_GL_ERROR(); | 2238 CHECK_GL_ERROR(); |
2226 | 2239 |
2227 disallowed_features_ = disallowed_features; | 2240 disallowed_features_ = disallowed_features; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2270 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); | 2283 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_CUBE_MAP); |
2271 state_.texture_units[tt].bound_texture_cube_map = ref; | 2284 state_.texture_units[tt].bound_texture_cube_map = ref; |
2272 glBindTexture(GL_TEXTURE_CUBE_MAP, ref->service_id()); | 2285 glBindTexture(GL_TEXTURE_CUBE_MAP, ref->service_id()); |
2273 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); | 2286 ref = texture_manager()->GetDefaultTextureInfo(GL_TEXTURE_2D); |
2274 state_.texture_units[tt].bound_texture_2d = ref; | 2287 state_.texture_units[tt].bound_texture_2d = ref; |
2275 glBindTexture(GL_TEXTURE_2D, ref->service_id()); | 2288 glBindTexture(GL_TEXTURE_2D, ref->service_id()); |
2276 } | 2289 } |
2277 glActiveTexture(GL_TEXTURE0); | 2290 glActiveTexture(GL_TEXTURE0); |
2278 CHECK_GL_ERROR(); | 2291 CHECK_GL_ERROR(); |
2279 | 2292 |
2280 ContextCreationAttribHelper attrib_parser; | |
2281 if (!attrib_parser.Parse(attribs)) | |
2282 return false; | |
2283 | |
2284 if (offscreen) { | 2293 if (offscreen) { |
2285 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && | 2294 if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && |
2286 features().chromium_framebuffer_multisample) { | 2295 features().chromium_framebuffer_multisample) { |
2287 // Per ext_framebuffer_multisample spec, need max bound on sample count. | 2296 // Per ext_framebuffer_multisample spec, need max bound on sample count. |
2288 // max_sample_count must be initialized to a sane value. If | 2297 // max_sample_count must be initialized to a sane value. If |
2289 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. | 2298 // glGetIntegerv() throws a GL error, it leaves its argument unchanged. |
2290 GLint max_sample_count = 1; | 2299 GLint max_sample_count = 1; |
2291 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); | 2300 glGetIntegerv(GL_MAX_SAMPLES_EXT, &max_sample_count); |
2292 offscreen_target_samples_ = std::min(attrib_parser.samples_, | 2301 offscreen_target_samples_ = std::min(attrib_parser.samples_, |
2293 max_sample_count); | 2302 max_sample_count); |
(...skipping 8217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10511 DoDidUseTexImageIfNeeded(texture, texture->target()); | 10520 DoDidUseTexImageIfNeeded(texture, texture->target()); |
10512 } | 10521 } |
10513 | 10522 |
10514 // Include the auto-generated part of this file. We split this because it means | 10523 // Include the auto-generated part of this file. We split this because it means |
10515 // we can easily edit the non-auto generated parts right here in this file | 10524 // we can easily edit the non-auto generated parts right here in this file |
10516 // instead of having to edit some template or the code generator. | 10525 // instead of having to edit some template or the code generator. |
10517 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10526 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
10518 | 10527 |
10519 } // namespace gles2 | 10528 } // namespace gles2 |
10520 } // namespace gpu | 10529 } // namespace gpu |
OLD | NEW |