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

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: Created 7 years, 7 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 4601 matching lines...) Expand 10 before | Expand all | Expand 10 after
7142 str = "OpenGL ES GLSL ES 1.0 Chromium"; 7148 str = "OpenGL ES GLSL ES 1.0 Chromium";
7143 break; 7149 break;
7144 case GL_RENDERER: 7150 case GL_RENDERER:
7145 str = "Chromium"; 7151 str = "Chromium";
7146 break; 7152 break;
7147 case GL_VENDOR: 7153 case GL_VENDOR:
7148 str = "Chromium"; 7154 str = "Chromium";
7149 break; 7155 break;
7150 case GL_EXTENSIONS: 7156 case GL_EXTENSIONS:
7151 { 7157 {
7152 // For WebGL contexts, strip out the OES derivatives extension if it has 7158 // For WebGL contexts, strip out the OES derivatives and
7153 // not been enabled. 7159 // EXT frag depth extensions if they have not been enabled.
7154 if (force_webgl_glsl_validation_ && 7160 if (force_webgl_glsl_validation_) {
7155 !derivatives_explicitly_enabled_) {
7156 extensions = feature_info_->extensions(); 7161 extensions = feature_info_->extensions();
7157 size_t offset = extensions.find(kOESDerivativeExtension); 7162 if (!derivatives_explicitly_enabled_) {
7158 if (std::string::npos != offset) { 7163 size_t offset = extensions.find(kOESDerivativeExtension);
7159 extensions.replace(offset, 7164 if (std::string::npos != offset) {
7160 offset + arraysize(kOESDerivativeExtension), 7165 extensions.replace(offset,
7161 std::string()); 7166 offset + arraysize(kOESDerivativeExtension),
7167 std::string());
7168 }
7169 }
7170 if (!frag_depth_explicitly_enabled_) {
7171 size_t offset = extensions.find(kEXTFragDepthExtension);
7172 if (std::string::npos != offset) {
7173 extensions.replace(offset,
7174 offset + arraysize(kEXTFragDepthExtension),
7175 std::string());
7176 }
7162 } 7177 }
7163 } else { 7178 } else {
7164 extensions = feature_info_->extensions().c_str(); 7179 extensions = feature_info_->extensions().c_str();
7165 } 7180 }
7166 std::string surface_extensions = surface_->GetExtensions(); 7181 std::string surface_extensions = surface_->GetExtensions();
7167 if (!surface_extensions.empty()) 7182 if (!surface_extensions.empty())
7168 extensions += " " + surface_extensions; 7183 extensions += " " + surface_extensions;
7169 str = extensions.c_str(); 7184 str = extensions.c_str();
7170 } 7185 }
7171 break; 7186 break;
(...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after
8876 return error::kInvalidArguments; 8891 return error::kInvalidArguments;
8877 } 8892 }
8878 std::string feature_str; 8893 std::string feature_str;
8879 if (!bucket->GetAsString(&feature_str)) { 8894 if (!bucket->GetAsString(&feature_str)) {
8880 return error::kInvalidArguments; 8895 return error::kInvalidArguments;
8881 } 8896 }
8882 8897
8883 bool desire_webgl_glsl_validation = 8898 bool desire_webgl_glsl_validation =
8884 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos; 8899 feature_str.find("GL_CHROMIUM_webglsl") != std::string::npos;
8885 bool desire_standard_derivatives = false; 8900 bool desire_standard_derivatives = false;
8901 bool desire_frag_depth = false;
8886 if (force_webgl_glsl_validation_) { 8902 if (force_webgl_glsl_validation_) {
8887 desire_standard_derivatives = 8903 desire_standard_derivatives =
8888 feature_str.find("GL_OES_standard_derivatives") != std::string::npos; 8904 feature_str.find("GL_OES_standard_derivatives") != std::string::npos;
8905 desire_frag_depth =
8906 feature_str.find("GL_EXT_frag_depth") != std::string::npos;
8889 } 8907 }
8890 8908
8891 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ || 8909 if (desire_webgl_glsl_validation != force_webgl_glsl_validation_ ||
8892 desire_standard_derivatives != derivatives_explicitly_enabled_) { 8910 desire_standard_derivatives != derivatives_explicitly_enabled_ ||
8893 force_webgl_glsl_validation_ = desire_webgl_glsl_validation; 8911 desire_frag_depth != frag_depth_explicitly_enabled_) {
8894 derivatives_explicitly_enabled_ = desire_standard_derivatives; 8912 force_webgl_glsl_validation_ |= desire_webgl_glsl_validation;
8913 derivatives_explicitly_enabled_ |= desire_standard_derivatives;
8914 frag_depth_explicitly_enabled_ |= desire_frag_depth;
8895 InitializeShaderTranslator(); 8915 InitializeShaderTranslator();
8896 } 8916 }
8897 8917
8898 UpdateCapabilities(); 8918 UpdateCapabilities();
8899 8919
8900 return error::kNoError; 8920 return error::kNoError;
8901 } 8921 }
8902 8922
8903 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM( 8923 error::Error GLES2DecoderImpl::HandleGetMultipleIntegervCHROMIUM(
8904 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) { 8924 uint32 immediate_data_size, const cmds::GetMultipleIntegervCHROMIUM& c) {
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
10351 return error::kNoError; 10371 return error::kNoError;
10352 } 10372 }
10353 10373
10354 // Include the auto-generated part of this file. We split this because it means 10374 // Include the auto-generated part of this file. We split this because it means
10355 // we can easily edit the non-auto generated parts right here in this file 10375 // we can easily edit the non-auto generated parts right here in this file
10356 // instead of having to edit some template or the code generator. 10376 // instead of having to edit some template or the code generator.
10357 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 10377 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
10358 10378
10359 } // namespace gles2 10379 } // namespace gles2
10360 } // namespace gpu 10380 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698