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

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

Issue 11791032: Refactor FeatureInfo so you can't request features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | 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 // 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 2100 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); 2111 this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp));
2112 2112
2113 attrib_0_value_.v[0] = 0.0f; 2113 attrib_0_value_.v[0] = 0.0f;
2114 attrib_0_value_.v[1] = 0.0f; 2114 attrib_0_value_.v[1] = 0.0f;
2115 attrib_0_value_.v[2] = 0.0f; 2115 attrib_0_value_.v[2] = 0.0f;
2116 attrib_0_value_.v[3] = 1.0f; 2116 attrib_0_value_.v[3] = 1.0f;
2117 2117
2118 // The shader translator is used for WebGL even when running on EGL 2118 // The shader translator is used for WebGL even when running on EGL
2119 // because additional restrictions are needed (like only enabling 2119 // because additional restrictions are needed (like only enabling
2120 // GL_OES_standard_derivatives on demand). It is used for the unit 2120 // GL_OES_standard_derivatives on demand). It is used for the unit
2121 // tests because 2121 // tests because GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes
2122 // GLES2DecoderWithShaderTest.GetShaderInfoLogValidArgs passes the 2122 // the empty string to CompileShader and this is not a valid shader.
2123 // empty string to CompileShader and this is not a valid shader. 2123 if (gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
2124 // TODO(apatrick): fix this test.
2125 if ((gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
2126 !features().chromium_webglsl && !force_webgl_glsl_validation_) ||
2127 gfx::GetGLImplementation() == gfx::kGLImplementationMockGL ||
2128 CommandLine::ForCurrentProcess()->HasSwitch( 2124 CommandLine::ForCurrentProcess()->HasSwitch(
2129 switches::kDisableGLSLTranslator)) { 2125 switches::kDisableGLSLTranslator)) {
2130 use_shader_translator_ = false; 2126 use_shader_translator_ = false;
2131 } 2127 }
2132 2128
2133 // TODO(gman): Consider setting this based on GPU and/or driver. 2129 // TODO(gman): Consider setting this based on GPU and/or driver.
2134 if (IsAngle()) { 2130 if (IsAngle()) {
2135 teximage2d_faster_than_texsubimage2d_ = false; 2131 teximage2d_faster_than_texsubimage2d_ = false;
2136 } 2132 }
2137 } 2133 }
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 void GLES2DecoderImpl::UpdateCapabilities() { 2442 void GLES2DecoderImpl::UpdateCapabilities() {
2447 util_.set_num_compressed_texture_formats( 2443 util_.set_num_compressed_texture_formats(
2448 validators_->compressed_texture_format.GetValues().size()); 2444 validators_->compressed_texture_format.GetValues().size());
2449 util_.set_num_shader_binary_formats( 2445 util_.set_num_shader_binary_formats(
2450 validators_->shader_binary_format.GetValues().size()); 2446 validators_->shader_binary_format.GetValues().size());
2451 } 2447 }
2452 2448
2453 bool GLES2DecoderImpl::InitializeShaderTranslator() { 2449 bool GLES2DecoderImpl::InitializeShaderTranslator() {
2454 TRACE_EVENT0("gpu", "GLES2DecoderImpl::InitializeShaderTranslator"); 2450 TRACE_EVENT0("gpu", "GLES2DecoderImpl::InitializeShaderTranslator");
2455 2451
2456 // Re-check the state of use_shader_translator_ each time this is called.
2457 if (gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 &&
2458 (features().chromium_webglsl || force_webgl_glsl_validation_) &&
2459 !use_shader_translator_) {
2460 use_shader_translator_ = true;
2461 }
2462 if (!use_shader_translator_) { 2452 if (!use_shader_translator_) {
2463 return true; 2453 return true;
2464 } 2454 }
2465 ShBuiltInResources resources; 2455 ShBuiltInResources resources;
2466 ShInitBuiltInResources(&resources); 2456 ShInitBuiltInResources(&resources);
2467 resources.MaxVertexAttribs = group_->max_vertex_attribs(); 2457 resources.MaxVertexAttribs = group_->max_vertex_attribs();
2468 resources.MaxVertexUniformVectors = 2458 resources.MaxVertexUniformVectors =
2469 group_->max_vertex_uniform_vectors(); 2459 group_->max_vertex_uniform_vectors();
2470 resources.MaxVaryingVectors = group_->max_varying_vectors(); 2460 resources.MaxVaryingVectors = group_->max_varying_vectors();
2471 resources.MaxVertexTextureImageUnits = 2461 resources.MaxVertexTextureImageUnits =
(...skipping 12 matching lines...) Expand all
2484 resources.ARB_texture_rectangle = 2474 resources.ARB_texture_rectangle =
2485 features().arb_texture_rectangle ? 1 : 0; 2475 features().arb_texture_rectangle ? 1 : 0;
2486 resources.OES_EGL_image_external = 2476 resources.OES_EGL_image_external =
2487 features().oes_egl_image_external ? 1 : 0; 2477 features().oes_egl_image_external ? 1 : 0;
2488 } 2478 }
2489 2479
2490 if (features().enable_shader_name_hashing) 2480 if (features().enable_shader_name_hashing)
2491 resources.HashFunction = &CityHashForAngle; 2481 resources.HashFunction = &CityHashForAngle;
2492 2482
2493 ShShaderSpec shader_spec = force_webgl_glsl_validation_ || 2483 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ||
2494 features().chromium_webglsl ? SH_WEBGL_SPEC : SH_GLES2_SPEC; 2484 force_webgl_glsl_validation_ ? SH_WEBGL_SPEC : SH_GLES2_SPEC;
2495 ShaderTranslatorInterface::GlslImplementationType implementation_type = 2485 ShaderTranslatorInterface::GlslImplementationType implementation_type =
2496 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ? 2486 gfx::GetGLImplementation() == gfx::kGLImplementationEGLGLES2 ?
2497 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl; 2487 ShaderTranslatorInterface::kGlslES : ShaderTranslatorInterface::kGlsl;
2498 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior function_behavior = 2488 ShaderTranslatorInterface::GlslBuiltInFunctionBehavior function_behavior =
2499 workarounds().needs_glsl_built_in_function_emulation ? 2489 workarounds().needs_glsl_built_in_function_emulation ?
2500 ShaderTranslatorInterface::kGlslBuiltInFunctionEmulated : 2490 ShaderTranslatorInterface::kGlslBuiltInFunctionEmulated :
2501 ShaderTranslatorInterface::kGlslBuiltInFunctionOriginal; 2491 ShaderTranslatorInterface::kGlslBuiltInFunctionOriginal;
2502 2492
2503 ShaderTranslatorCache* cache = ShaderTranslatorCache::GetInstance(); 2493 ShaderTranslatorCache* cache = ShaderTranslatorCache::GetInstance();
2504 vertex_translator_ = cache->GetTranslator( 2494 vertex_translator_ = cache->GetTranslator(
(...skipping 6241 matching lines...) Expand 10 before | Expand all | Expand 10 after
8746 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) { 8736 uint32 immediate_data_size, const gles2::RequestExtensionCHROMIUM& c) {
8747 Bucket* bucket = GetBucket(c.bucket_id); 8737 Bucket* bucket = GetBucket(c.bucket_id);
8748 if (!bucket || bucket->size() == 0) { 8738 if (!bucket || bucket->size() == 0) {
8749 return error::kInvalidArguments; 8739 return error::kInvalidArguments;
8750 } 8740 }
8751 std::string feature_str; 8741 std::string feature_str;
8752 if (!bucket->GetAsString(&feature_str)) { 8742 if (!bucket->GetAsString(&feature_str)) {
8753 return error::kInvalidArguments; 8743 return error::kInvalidArguments;
8754 } 8744 }
8755 8745
8756 bool std_derivatives_enabled = features().oes_standard_derivatives; 8746 bool desire_webgl_glsl_validation =
8757 bool webglsl_enabled = features().chromium_webglsl; 8747 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos;
8758 8748 bool desire_standard_derivatives = false;
8759 feature_info_->AddFeatures(feature_str.c_str()); 8749 if (force_webgl_glsl_validation_) {
8760 8750 desire_standard_derivatives =
8761 bool initialization_required = false; 8751 feature_str.find("GL_OES_standard_derivatives") != std::string::npos;
8762 if (force_webgl_glsl_validation_ && !derivatives_explicitly_enabled_) {
8763 size_t derivatives_offset = feature_str.find(kOESDerivativeExtension);
8764 if (std::string::npos != derivatives_offset) {
8765 derivatives_explicitly_enabled_ = true;
8766 initialization_required = true;
8767 }
8768 } 8752 }
8769 8753
8770 // If we just enabled a feature which affects the shader translator, 8754 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ ||
8771 // we may need to re-initialize it. 8755 desire_standard_derivatives != derivatives_explicitly_enabled_) {
8772 if (std_derivatives_enabled != features().oes_standard_derivatives || 8756 force_webgl_glsl_validation_ = desire_webgl_glsl_validation;
8773 webglsl_enabled != features().chromium_webglsl || 8757 derivatives_explicitly_enabled_ = desire_standard_derivatives;
8774 initialization_required) {
8775 InitializeShaderTranslator(); 8758 InitializeShaderTranslator();
8776 } 8759 }
8777 8760
8778 UpdateCapabilities(); 8761 UpdateCapabilities();
8779 8762
8780 return error::kNoError; 8763 return error::kNoError;
8781 } 8764 }
8782 8765
8783 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 8766 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
8784 uint32 immediate_data_size, const gles2::GetMultipleIntegervCHROMIUM& c) { 8767 uint32 immediate_data_size, const gles2::GetMultipleIntegervCHROMIUM& c) {
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10006 return error::kNoError; 9989 return error::kNoError;
10007 } 9990 }
10008 9991
10009 // Include the auto-generated part of this file. We split this because it means 9992 // Include the auto-generated part of this file. We split this because it means
10010 // we can easily edit the non-auto generated parts right here in this file 9993 // we can easily edit the non-auto generated parts right here in this file
10011 // instead of having to edit some template or the code generator. 9994 // instead of having to edit some template or the code generator.
10012 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9995 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10013 9996
10014 } // namespace gles2 9997 } // namespace gles2
10015 } // namespace gpu 9998 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698