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/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 (extensions.Contains("GL_ANGLE_instanced_arrays") || | 1148 (extensions.Contains("GL_ANGLE_instanced_arrays") || |
1149 (extensions.Contains("GL_ARB_instanced_arrays") && | 1149 (extensions.Contains("GL_ARB_instanced_arrays") && |
1150 extensions.Contains("GL_ARB_draw_instanced")) || | 1150 extensions.Contains("GL_ARB_draw_instanced")) || |
1151 gl_version_info_->is_es3 || | 1151 gl_version_info_->is_es3 || |
1152 gl_version_info_->is_desktop_core_profile)) { | 1152 gl_version_info_->is_desktop_core_profile)) { |
1153 AddExtensionString("GL_ANGLE_instanced_arrays"); | 1153 AddExtensionString("GL_ANGLE_instanced_arrays"); |
1154 feature_flags_.angle_instanced_arrays = true; | 1154 feature_flags_.angle_instanced_arrays = true; |
1155 validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); | 1155 validators_.vertex_attribute.AddValue(GL_VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE); |
1156 } | 1156 } |
1157 | 1157 |
1158 bool vendor_agnostic_draw_buffers = | 1158 bool have_es2_draw_buffers_vendor_agnostic = |
1159 gl_version_info_->is_desktop_core_profile || | |
1159 extensions.Contains("GL_ARB_draw_buffers") || | 1160 extensions.Contains("GL_ARB_draw_buffers") || |
1160 extensions.Contains("GL_EXT_draw_buffers"); | 1161 extensions.Contains("GL_EXT_draw_buffers"); |
1161 if (!workarounds_.disable_ext_draw_buffers && | 1162 bool can_emulate_es2_draw_buffers_on_es3_nv = |
1162 (vendor_agnostic_draw_buffers || | 1163 gl_version_info_->is_es3 && extensions.Contains("GL_NV_draw_buffers"); |
1163 (extensions.Contains("GL_NV_draw_buffers") && | 1164 bool have_es2_draw_buffers = !workarounds_.disable_ext_draw_buffers && |
1164 gl_version_info_->is_es3) || | 1165 IsWebGL1OrES2Context() && |
1165 gl_version_info_->is_desktop_core_profile)) { | 1166 (have_es2_draw_buffers_vendor_agnostic || |
1167 can_emulate_es2_draw_buffers_on_es3_nv); | |
Zhenyao Mo
2017/02/17 19:17:44
This is neat, much more readable
| |
1168 if (have_es2_draw_buffers) { | |
1166 AddExtensionString("GL_EXT_draw_buffers"); | 1169 AddExtensionString("GL_EXT_draw_buffers"); |
1167 feature_flags_.ext_draw_buffers = true; | 1170 feature_flags_.ext_draw_buffers = true; |
1168 | 1171 |
1169 // This flag is set to enable emulation of EXT_draw_buffers when we're | 1172 // This flag is set to enable emulation of EXT_draw_buffers when we're |
1170 // running on GLES 3.0+, NV_draw_buffers extension is supported and | 1173 // running on GLES 3.0+, NV_draw_buffers extension is supported and |
1171 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the | 1174 // glDrawBuffers from GLES 3.0 core has been bound. It toggles using the |
1172 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension | 1175 // NV_draw_buffers extension directive instead of EXT_draw_buffers extension |
1173 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write | 1176 // directive in ESSL 100 shaders translated by ANGLE, enabling them to write |
1174 // into multiple gl_FragData values, which is not by default possible in | 1177 // into multiple gl_FragData values, which is not by default possible in |
1175 // ESSL 100 with core GLES 3.0. For more information, see the | 1178 // ESSL 100 with core GLES 3.0. For more information, see the |
1176 // NV_draw_buffers specification. | 1179 // NV_draw_buffers specification. |
1177 feature_flags_.nv_draw_buffers = !vendor_agnostic_draw_buffers; | 1180 feature_flags_.nv_draw_buffers = can_emulate_es2_draw_buffers_on_es3_nv && |
1181 !have_es2_draw_buffers_vendor_agnostic; | |
1182 } | |
1178 | 1183 |
1184 if (IsWebGL2OrES3Context() || have_es2_draw_buffers) { | |
1179 GLint max_color_attachments = 0; | 1185 GLint max_color_attachments = 0; |
1180 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments); | 1186 glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &max_color_attachments); |
1181 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT; | 1187 for (GLenum i = GL_COLOR_ATTACHMENT1_EXT; |
1182 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments); | 1188 i < static_cast<GLenum>(GL_COLOR_ATTACHMENT0 + max_color_attachments); |
1183 ++i) { | 1189 ++i) { |
1184 validators_.attachment.AddValue(i); | 1190 validators_.attachment.AddValue(i); |
1185 validators_.attachment_query.AddValue(i); | 1191 validators_.attachment_query.AddValue(i); |
1186 } | 1192 } |
1187 static_assert(GL_COLOR_ATTACHMENT0_EXT == GL_COLOR_ATTACHMENT0, | 1193 static_assert(GL_COLOR_ATTACHMENT0_EXT == GL_COLOR_ATTACHMENT0, |
1188 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0"); | 1194 "GL_COLOR_ATTACHMENT0_EXT should equal GL_COLOR_ATTACHMENT0"); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 if (pos == std::string::npos) { | 1550 if (pos == std::string::npos) { |
1545 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1551 extensions_ += (extensions_.empty() ? "" : " ") + str; |
1546 } | 1552 } |
1547 } | 1553 } |
1548 | 1554 |
1549 FeatureInfo::~FeatureInfo() { | 1555 FeatureInfo::~FeatureInfo() { |
1550 } | 1556 } |
1551 | 1557 |
1552 } // namespace gles2 | 1558 } // namespace gles2 |
1553 } // namespace gpu | 1559 } // namespace gpu |
OLD | NEW |