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

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: ANGLE DEPS roll 2245:2249 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 1580 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 bool has_robustness_extension_; 1668 bool has_robustness_extension_;
1668 GLenum reset_status_; 1669 GLenum reset_status_;
1669 1670
1670 // These flags are used to override the state of the shared feature_info_ 1671 // These flags are used to override the state of the shared feature_info_
1671 // member. Because the same FeatureInfo instance may be shared among many 1672 // member. Because the same FeatureInfo instance may be shared among many
1672 // contexts, the assumptions on the availablity of extensions in WebGL 1673 // contexts, the assumptions on the availablity of extensions in WebGL
1673 // contexts may be broken. These flags override the shared state to preserve 1674 // contexts may be broken. These flags override the shared state to preserve
1674 // WebGL semantics. 1675 // WebGL semantics.
1675 bool force_webgl_glsl_validation_; 1676 bool force_webgl_glsl_validation_;
1676 bool derivatives_explicitly_enabled_; 1677 bool derivatives_explicitly_enabled_;
1678 bool frag_depth_explicitly_enabled_;
1677 1679
1678 bool compile_shader_always_succeeds_; 1680 bool compile_shader_always_succeeds_;
1679 1681
1680 // Log extra info. 1682 // Log extra info.
1681 bool service_logging_; 1683 bool service_logging_;
1682 1684
1683 #if defined(OS_MACOSX) 1685 #if defined(OS_MACOSX)
1684 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap; 1686 typedef std::map<GLuint, CFTypeRef> TextureToIOSurfaceMap;
1685 TextureToIOSurfaceMap texture_to_io_surface_map_; 1687 TextureToIOSurfaceMap texture_to_io_surface_map_;
1686 #endif 1688 #endif
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2121 current_decoder_error_(error::kNoError), 2123 current_decoder_error_(error::kNoError),
2122 use_shader_translator_(true), 2124 use_shader_translator_(true),
2123 validators_(group_->feature_info()->validators()), 2125 validators_(group_->feature_info()->validators()),
2124 feature_info_(group_->feature_info()), 2126 feature_info_(group_->feature_info()),
2125 tex_image_2d_failed_(false), 2127 tex_image_2d_failed_(false),
2126 frame_number_(0), 2128 frame_number_(0),
2127 has_robustness_extension_(false), 2129 has_robustness_extension_(false),
2128 reset_status_(GL_NO_ERROR), 2130 reset_status_(GL_NO_ERROR),
2129 force_webgl_glsl_validation_(false), 2131 force_webgl_glsl_validation_(false),
2130 derivatives_explicitly_enabled_(false), 2132 derivatives_explicitly_enabled_(false),
2133 frag_depth_explicitly_enabled_(false),
2131 compile_shader_always_succeeds_(false), 2134 compile_shader_always_succeeds_(false),
2132 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( 2135 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
2133 switches::kEnableGPUServiceLoggingGPU)), 2136 switches::kEnableGPUServiceLoggingGPU)),
2134 viewport_max_width_(0), 2137 viewport_max_width_(0),
2135 viewport_max_height_(0), 2138 viewport_max_height_(0),
2136 texture_upload_count_(0) { 2139 texture_upload_count_(0) {
2137 DCHECK(group); 2140 DCHECK(group);
2138 2141
2139 attrib_0_value_.v[0] = 0.0f; 2142 attrib_0_value_.v[0] = 0.0f;
2140 attrib_0_value_.v[1] = 0.0f; 2143 attrib_0_value_.v[1] = 0.0f;
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 GLint precision = 0; 2515 GLint precision = 0;
2513 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT, 2516 GetShaderPrecisionFormatImpl(GL_FRAGMENT_SHADER, GL_HIGH_FLOAT,
2514 range, &precision); 2517 range, &precision);
2515 resources.FragmentPrecisionHigh = ((range[0] >= 62) && 2518 resources.FragmentPrecisionHigh = ((range[0] >= 62) &&
2516 (range[1] >= 62) && 2519 (range[1] >= 62) &&
2517 (precision >= 16)); 2520 (precision >= 16));
2518 #endif 2521 #endif
2519 2522
2520 if (force_webgl_glsl_validation_) { 2523 if (force_webgl_glsl_validation_) {
2521 resources.OES_standard_derivatives = derivatives_explicitly_enabled_; 2524 resources.OES_standard_derivatives = derivatives_explicitly_enabled_;
2525 resources.EXT_frag_depth = frag_depth_explicitly_enabled_;
2522 } else { 2526 } else {
2523 resources.OES_standard_derivatives = 2527 resources.OES_standard_derivatives =
2524 features().oes_standard_derivatives ? 1 : 0; 2528 features().oes_standard_derivatives ? 1 : 0;
2525 resources.ARB_texture_rectangle = 2529 resources.ARB_texture_rectangle =
2526 features().arb_texture_rectangle ? 1 : 0; 2530 features().arb_texture_rectangle ? 1 : 0;
2527 resources.OES_EGL_image_external = 2531 resources.OES_EGL_image_external =
2528 features().oes_egl_image_external ? 1 : 0; 2532 features().oes_egl_image_external ? 1 : 0;
2529 resources.EXT_draw_buffers = 2533 resources.EXT_draw_buffers =
2530 features().ext_draw_buffers ? 1 : 0; 2534 features().ext_draw_buffers ? 1 : 0;
2535 resources.EXT_frag_depth =
2536 features().ext_frag_depth ? 1 : 0;
2531 } 2537 }
2532 2538
2533 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC 2539 ShShaderSpec shader_spec = force_webgl_glsl_validation_ ? SH_WEBGL_SPEC
2534 : SH_GLES2_SPEC; 2540 : SH_GLES2_SPEC;
2535 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing) 2541 if (shader_spec == SH_WEBGL_SPEC && features().enable_shader_name_hashing)
2536 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108 2542 #if !defined(ANGLE_SH_VERSION) || ANGLE_SH_VERSION < 108
2537 resources.HashFunction = &CityHashForAngle; 2543 resources.HashFunction = &CityHashForAngle;
2538 #else 2544 #else
2539 resources.HashFunction = &CityHash64; 2545 resources.HashFunction = &CityHash64;
2540 #endif 2546 #endif
(...skipping 4604 matching lines...) Expand 10 before | Expand all | Expand 10 after
7145 str = "OpenGL ES GLSL ES 1.0 Chromium"; 7151 str = "OpenGL ES GLSL ES 1.0 Chromium";
7146 break; 7152 break;
7147 case GL_RENDERER: 7153 case GL_RENDERER:
7148 str = "Chromium"; 7154 str = "Chromium";
7149 break; 7155 break;
7150 case GL_VENDOR: 7156 case GL_VENDOR:
7151 str = "Chromium"; 7157 str = "Chromium";
7152 break; 7158 break;
7153 case GL_EXTENSIONS: 7159 case GL_EXTENSIONS:
7154 { 7160 {
7155 // For WebGL contexts, strip out the OES derivatives extension if it has 7161 // For WebGL contexts, strip out the OES derivatives and
7156 // not been enabled. 7162 // EXT frag depth extensions if they have not been enabled.
7157 if (force_webgl_glsl_validation_ && 7163 if (force_webgl_glsl_validation_) {
7158 !derivatives_explicitly_enabled_) {
7159 extensions = feature_info_->extensions(); 7164 extensions = feature_info_->extensions();
7160 size_t offset = extensions.find(kOESDerivativeExtension); 7165 if (!derivatives_explicitly_enabled_) {
7161 if (std::string::npos != offset) { 7166 size_t offset = extensions.find(kOESDerivativeExtension);
7162 extensions.replace(offset, 7167 if (std::string::npos != offset) {
7163 offset + arraysize(kOESDerivativeExtension), 7168 extensions.replace(offset,
7164 std::string()); 7169 offset + arraysize(kOESDerivativeExtension),
7170 std::string());
7171 }
7172 }
7173 if (!frag_depth_explicitly_enabled_) {
7174 size_t offset = extensions.find(kEXTFragDepthExtension);
7175 if (std::string::npos != offset) {
7176 extensions.replace(offset,
7177 offset + arraysize(kEXTFragDepthExtension),
7178 std::string());
7179 }
7165 } 7180 }
7166 } else { 7181 } else {
7167 extensions = feature_info_->extensions().c_str(); 7182 extensions = feature_info_->extensions().c_str();
7168 } 7183 }
7169 std::string surface_extensions = surface_->GetExtensions(); 7184 std::string surface_extensions = surface_->GetExtensions();
7170 if (!surface_extensions.empty()) 7185 if (!surface_extensions.empty())
7171 extensions += " " + surface_extensions; 7186 extensions += " " + surface_extensions;
7172 str = extensions.c_str(); 7187 str = extensions.c_str();
7173 } 7188 }
7174 break; 7189 break;
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
8879 return error::kInvalidArguments; 8894 return error::kInvalidArguments;
8880 } 8895 }
8881 std::string feature_str; 8896 std::string feature_str;
8882 if (!bucket->GetAsString(&feature_str)) { 8897 if (!bucket->GetAsString(&feature_str)) {
8883 return error::kInvalidArguments; 8898 return error::kInvalidArguments;
8884 } 8899 }
8885 8900
8886 bool desire_webgl_glsl_validation = 8901 bool desire_webgl_glsl_validation =
8887 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; 8902 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos;
8888 bool desire_standard_derivatives = false; 8903 bool desire_standard_derivatives = false;
8904 bool desire_frag_depth = false;
8889 if (force_webgl_glsl_validation_) { 8905 if (force_webgl_glsl_validation_) {
8890 desire_standard_derivatives = 8906 desire_standard_derivatives =
8891 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; 8907 feature_str.find("GL_OES_standard_derivatives") != std::string::npos;
8908 desire_frag_depth =
8909 feature_str.find("GL_EXT_frag_depth") != std::string::npos;
8892 } 8910 }
8893 8911
8894 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ || 8912 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ ||
8895 desire_standard_derivatives != derivatives_explicitly_enabled_) { 8913 desire_standard_derivatives != derivatives_explicitly_enabled_ ||
8896 force_webgl_glsl_validation_ = desire_webgl_glsl_validation; 8914 desire_frag_depth != frag_depth_explicitly_enabled_) {
8897 derivatives_explicitly_enabled_ = desire_standard_derivatives; 8915 force_webgl_glsl_validation_ |= desire_webgl_glsl_validation;
8916 derivatives_explicitly_enabled_ |= desire_standard_derivatives;
8917 frag_depth_explicitly_enabled_ |= desire_frag_depth;
8898 InitializeShaderTranslator(); 8918 InitializeShaderTranslator();
8899 } 8919 }
8900 8920
8901 UpdateCapabilities(); 8921 UpdateCapabilities();
8902 8922
8903 return error::kNoError; 8923 return error::kNoError;
8904 } 8924 }
8905 8925
8906 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 8926 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
8907 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) { 8927 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) {
(...skipping 1446 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

Powered by Google App Engine
This is Rietveld 408576698