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

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

Issue 15846014: Added support for EXT_frag_depth (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebasing Created 7 years, 6 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
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 // TODO(zmo): we can't include "City.h" due to type def conflicts. 68 // TODO(zmo): we can't include "City.h" due to type def conflicts.
69 extern uint64 CityHash64(const char*, size_t); 69 extern uint64 CityHash64(const char*, size_t);
70 70
71 namespace gpu { 71 namespace gpu {
72 namespace gles2 { 72 namespace gles2 {
73 73
74 namespace { 74 namespace {
75 75
76 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives"; 76 static const char kOESDerivativeExtension[] = "GL_OES_standard_derivatives";
77 static const char kEXTFragDepthExtension[] = "GL_EXT_frag_depth";
77 78
78 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 79 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
79 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) { 80 khronos_uint64_t CityHashForAngle(const char* name, unsigned int len) {
80 return static_cast<khronos_uint64_t>( 81 return static_cast<khronos_uint64_t>(
81 CityHash64(name, static_cast<size_t>(len))); 82 CityHash64(name, static_cast<size_t>(len)));
82 } 83 }
83 #endif 84 #endif
84 85
85 static void GetShaderPrecisionFormatImpl(GLenum shader_type, 86 static void GetShaderPrecisionFormatImpl(GLenum shader_type,
86 GLenum precision_type, 87 GLenum precision_type,
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after
1669 bool has_robustness_extension_; 1670 bool has_robustness_extension_;
1670 GLenum reset_status_; 1671 GLenum reset_status_;
1671 1672
1672 // These flags are used to override the state of the shared feature_info_ 1673 // These flags are used to override the state of the shared feature_info_
1673 // member. Because the same FeatureInfo instance may be shared among many 1674 // member. Because the same FeatureInfo instance may be shared among many
1674 // contexts, the assumptions on the availablity of extensions in WebGL 1675 // contexts, the assumptions on the availablity of extensions in WebGL
1675 // contexts may be broken. These flags override the shared state to preserve 1676 // contexts may be broken. These flags override the shared state to preserve
1676 // WebGL semantics. 1677 // WebGL semantics.
1677 bool force_webgl_glsl_validation_; 1678 bool force_webgl_glsl_validation_;
1678 bool derivatives_explicitly_enabled_; 1679 bool derivatives_explicitly_enabled_;
1680 bool frag_depth_explicitly_enabled_;
1679 1681
1680 bool compile_shader_always_succeeds_; 1682 bool compile_shader_always_succeeds_;
1681 1683
1682 // Log extra info. 1684 // Log extra info.
1683 bool service_logging_; 1685 bool service_logging_;
1684 1686
1685 #if defined(OS_MACOSX) 1687 #if defined(OS_MACOSX)
1686 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; 1688 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap;
1687 TextureToIOSurfaceMap texture_to_io_surface_map_; 1689 TextureToIOSurfaceMap texture_to_io_surface_map_;
1688 #endif 1690 #endif
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 current_decoder_error_(error::kNoError), 2125 current_decoder_error_(error::kNoError),
2124 use_shader_translator_(true), 2126 use_shader_translator_(true),
2125 validators_(group_->feature_info()->validators()), 2127 validators_(group_->feature_info()->validators()),
2126 feature_info_(group_->feature_info()), 2128 feature_info_(group_->feature_info()),
2127 tex_image_2d_failed_(false), 2129 tex_image_2d_failed_(false),
2128 frame_number_(0), 2130 frame_number_(0),
2129 has_robustness_extension_(false), 2131 has_robustness_extension_(false),
2130 reset_status_(GL_NO_ERROR), 2132 reset_status_(GL_NO_ERROR),
2131 force_webgl_glsl_validation_(false), 2133 force_webgl_glsl_validation_(false),
2132 derivatives_explicitly_enabled_(false), 2134 derivatives_explicitly_enabled_(false),
2135 frag_depth_explicitly_enabled_(false),
2133 compile_shader_always_succeeds_(false), 2136 compile_shader_always_succeeds_(false),
2134 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( 2137 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
2135 switches::kEnableGPUServiceLoggingGPU)), 2138 switches::kEnableGPUServiceLoggingGPU)),
2136 viewport_max_width_(0), 2139 viewport_max_width_(0),
2137 viewport_max_height_(0), 2140 viewport_max_height_(0),
2138 texture_upload_count_(0) { 2141 texture_upload_count_(0) {
2139 DCHECK(group); 2142 DCHECK(group);
2140 2143
2141 attrib_0_value_.v[0] = 0.0f; 2144 attrib_0_value_.v[0] = 0.0f;
2142 attrib_0_value_.v[1] = 0.0f; 2145 attrib_0_value_.v[1] = 0.0f;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2514 GLint precision = 0; 2517 GLint precision = 0;
2515 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, 2518 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
2516 range, &precision); 2519 range, &precision);
2517 resources.FragmentPrecisionHigh = ((range[0] >= 62) && 2520 resources.FragmentPrecisionHigh = ((range[0] >= 62) &&
2518 (range[1] >= 62) && 2521 (range[1] >= 62) &&
2519 (precision >= 16)); 2522 (precision >= 16));
2520 #endif 2523 #endif
2521 2524
2522 if (force_webgl_glsl_validation_) { 2525 if (force_webgl_glsl_validation_) {
2523 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; 2526 resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
2527 resources.EXT_frag_depth = frag_depth_explicitly_enabled_;
2524 } else { 2528 } else {
2525 resources.OES_standard_derivatives = 2529 resources.OES_standard_derivatives =
2526 features().oes_standard_derivatives ? 1 : 0; 2530 features().oes_standard_derivatives ? 1 : 0;
2527 resources.ARB_texture_rectangle = 2531 resources.ARB_texture_rectangle =
2528 features().arb_texture_rectangle ? 1 : 0; 2532 features().arb_texture_rectangle ? 1 : 0;
2529 resources.OES_EGL_image_external = 2533 resources.OES_EGL_image_external =
2530 features().oes_egl_image_external ? 1 : 0; 2534 features().oes_egl_image_external ? 1 : 0;
2531 resources.EXT_draw_buffers = 2535 resources.EXT_draw_buffers =
2532 features().ext_draw_buffers ? 1 : 0; 2536 features().ext_draw_buffers ? 1 : 0;
2537 resources.EXT_frag_depth =
2538 features().ext_frag_depth ? 1 : 0;
2533 } 2539 }
2534 2540
2535 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC 2541 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC
2536 : SH_GLES2_SPEC; 2542 : SH_GLES2_SPEC;
2537 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) 2543 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing)
2538 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 2544 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
2539 resources.HashFunction = &CityHashForAngle; 2545 resources.HashFunction = &CityHashForAngle;
2540 #else 2546 #else
2541 resources.HashFunction = &CityHash64; 2547 resources.HashFunction = &CityHash64;
2542 #endif 2548 #endif
(...skipping 4582 matching lines...) Expand 10 before | Expand all | Expand 10 after
7125 str = "OpenGL ES GLSL ES 1.0 Chromium"; 7131 str = "OpenGL ES GLSL ES 1.0 Chromium";
7126 break; 7132 break;
7127 case GL_RENDERER: 7133 case GL_RENDERER:
7128 str = "Chromium"; 7134 str = "Chromium";
7129 break; 7135 break;
7130 case GL_VENDOR: 7136 case GL_VENDOR:
7131 str = "Chromium"; 7137 str = "Chromium";
7132 break; 7138 break;
7133 case GL_EXTENSIONS: 7139 case GL_EXTENSIONS:
7134 { 7140 {
7135 // For WebGL contexts, strip out the OES derivatives extension if it has 7141 // For WebGL contexts, strip out the OES derivatives and
7136 // not been enabled. 7142 // EXT frag depth extensions if they have not been enabled.
7137 if (force_webgl_glsl_validation_ && 7143 if (force_webgl_glsl_validation_) {
7138 !derivatives_explicitly_enabled_) {
7139 extensions = feature_info_->extensions(); 7144 extensions = feature_info_->extensions();
7140 size_t offset = extensions.find(kOESDerivativeExtension); 7145 if (!derivatives_explicitly_enabled_) {
7141 if (std::string::npos != offset) { 7146 size_t offset = extensions.find(kOESDerivativeExtension);
7142 extensions.replace(offset, 7147 if (std::string::npos != offset) {
7143 offset + arraysize(kOESDerivativeExtension), 7148 extensions.replace(offset,
7144 std::string()); 7149 offset + arraysize(kOESDerivativeExtension),
7150 std::string());
7151 }
7152 }
7153 if (!frag_depth_explicitly_enabled_) {
7154 size_t offset = extensions.find(kEXTFragDepthExtension);
7155 if (std::string::npos != offset) {
7156 extensions.replace(offset,
7157 offset + arraysize(kEXTFragDepthExtension),
7158 std::string());
7159 }
7145 } 7160 }
7146 } else { 7161 } else {
7147 extensions = feature_info_->extensions().c_str(); 7162 extensions = feature_info_->extensions().c_str();
7148 } 7163 }
7149 std::string surface_extensions = surface_->GetExtensions(); 7164 std::string surface_extensions = surface_->GetExtensions();
7150 if (!surface_extensions.empty()) 7165 if (!surface_extensions.empty())
7151 extensions += " " + surface_extensions; 7166 extensions += " " + surface_extensions;
7152 str = extensions.c_str(); 7167 str = extensions.c_str();
7153 } 7168 }
7154 break; 7169 break;
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
8859 return error::kInvalidArguments; 8874 return error::kInvalidArguments;
8860 } 8875 }
8861 std::string feature_str; 8876 std::string feature_str;
8862 if (!bucket->GetAsString(&feature_str)) { 8877 if (!bucket->GetAsString(&feature_str)) {
8863 return error::kInvalidArguments; 8878 return error::kInvalidArguments;
8864 } 8879 }
8865 8880
8866 bool desire_webgl_glsl_validation = 8881 bool desire_webgl_glsl_validation =
8867 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; 8882 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos;
8868 bool desire_standard_derivatives = false; 8883 bool desire_standard_derivatives = false;
8884 bool desire_frag_depth = false;
8869 if (force_webgl_glsl_validation_) { 8885 if (force_webgl_glsl_validation_) {
8870 desire_standard_derivatives = 8886 desire_standard_derivatives =
8871 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; 8887 feature_str.find("GL_OES_standard_derivatives") != std::string::npos;
8888 desire_frag_depth =
8889 feature_str.find("GL_EXT_frag_depth") != std::string::npos;
8872 } 8890 }
8873 8891
8874 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ || 8892 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ ||
8875 desire_standard_derivatives != derivatives_explicitly_enabled_) { 8893 desire_standard_derivatives != derivatives_explicitly_enabled_ ||
8876 force_webgl_glsl_validation_ = desire_webgl_glsl_validation; 8894 desire_frag_depth != frag_depth_explicitly_enabled_) {
8877 derivatives_explicitly_enabled_ = desire_standard_derivatives; 8895 force_webgl_glsl_validation_ |= desire_webgl_glsl_validation;
8896 derivatives_explicitly_enabled_ |= desire_standard_derivatives;
8897 frag_depth_explicitly_enabled_ |= desire_frag_depth;
8878 InitializeShaderTranslator(); 8898 InitializeShaderTranslator();
8879 } 8899 }
8880 8900
8881 UpdateCapabilities(); 8901 UpdateCapabilities();
8882 8902
8883 return error::kNoError; 8903 return error::kNoError;
8884 } 8904 }
8885 8905
8886 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 8906 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
8887 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) { 8907 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) {
(...skipping 1466 matching lines...) Expand 10 before | Expand all | Expand 10 after
10354 return error::kNoError; 10374 return error::kNoError;
10355 } 10375 }
10356 10376
10357 // Include the auto-generated part of this file. We split this because it means 10377 // Include the auto-generated part of this file. We split this because it means
10358 // we can easily edit the non-auto generated parts right here in this file 10378 // we can easily edit the non-auto generated parts right here in this file
10359 // instead of having to edit some template or the code generator. 10379 // instead of having to edit some template or the code generator.
10360 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10380 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10361 10381
10362 } // namespace gles2 10382 } // namespace gles2
10363 } // namespace gpu 10383 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info_unittest.cc ('k') | gpu/command_buffer/service/shader_translator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698