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

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

Issue 10441087: Plum through ANGLE_depth_texture (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 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
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/feature_info.h" 5 #include "gpu/command_buffer/service/feature_info.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "gpu/command_buffer/service/gl_utils.h" 11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #if defined(OS_MACOSX) 14 #if defined(OS_MACOSX)
15 #include "ui/surface/io_surface_support_mac.h" 15 #include "ui/surface/io_surface_support_mac.h"
16 #endif 16 #endif
17 17
18 namespace gpu { 18 namespace gpu {
19 namespace gles2 { 19 namespace gles2 {
20 20
21 namespace {
22
23 struct FormatInfo {
24 GLenum format;
25 const GLenum* types;
26 size_t count;
27 };
28
29 } // anonymous namespace.
30
21 FeatureInfo::FeatureInfo() { 31 FeatureInfo::FeatureInfo() {
32 static const GLenum kAlphaTypes[] = {
33 GL_UNSIGNED_BYTE,
34 };
35 static const GLenum kRGBTypes[] = {
36 GL_UNSIGNED_BYTE,
37 GL_UNSIGNED_SHORT_5_6_5,
38 };
39 static const GLenum kRGBATypes[] = {
40 GL_UNSIGNED_BYTE,
41 GL_UNSIGNED_SHORT_4_4_4_4,
42 GL_UNSIGNED_SHORT_5_5_5_1,
43 };
44 static const GLenum kLuminanceTypes[] = {
45 GL_UNSIGNED_BYTE,
46 };
47 static const GLenum kLuminanceAlphaTypes[] = {
48 GL_UNSIGNED_BYTE,
49 };
50 static const FormatInfo kFormatTypes[] = {
51 { GL_ALPHA, kAlphaTypes, arraysize(kAlphaTypes), },
52 { GL_RGB, kRGBTypes, arraysize(kRGBTypes), },
53 { GL_RGBA, kRGBATypes, arraysize(kRGBATypes), },
54 { GL_LUMINANCE, kLuminanceTypes, arraysize(kLuminanceTypes), },
55 { GL_LUMINANCE_ALPHA, kLuminanceAlphaTypes,
56 arraysize(kLuminanceAlphaTypes), } ,
57 };
58 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) {
59 const FormatInfo& info = kFormatTypes[ii];
60 ValueValidator<GLenum>& validator = texture_format_validators_[info.format];
61 for (size_t jj = 0; jj < info.count; ++jj) {
62 validator.AddValue(info.types[jj]);
63 }
64 }
22 } 65 }
23 66
24 // Helps query for extensions. 67 // Helps query for extensions.
25 class ExtensionHelper { 68 class ExtensionHelper {
26 public: 69 public:
27 ExtensionHelper(const char* extensions, const char* desired_features) 70 ExtensionHelper(const char* extensions, const char* desired_features)
28 : desire_all_features_(false) { 71 : desire_all_features_(false) {
29 // Check for "*" 72 // Check for "*"
30 if (desired_features && 73 if (desired_features &&
31 desired_features[0] == '*' && 74 desired_features[0] == '*' &&
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Check if we should enable GL_EXT_texture_filter_anisotropic. 248 // Check if we should enable GL_EXT_texture_filter_anisotropic.
206 if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) { 249 if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) {
207 AddExtensionString("GL_EXT_texture_filter_anisotropic"); 250 AddExtensionString("GL_EXT_texture_filter_anisotropic");
208 validators_.texture_parameter.AddValue( 251 validators_.texture_parameter.AddValue(
209 GL_TEXTURE_MAX_ANISOTROPY_EXT); 252 GL_TEXTURE_MAX_ANISOTROPY_EXT);
210 validators_.g_l_state.AddValue( 253 validators_.g_l_state.AddValue(
211 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); 254 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
212 } 255 }
213 256
214 // Check if we should support GL_OES_packed_depth_stencil and/or 257 // Check if we should support GL_OES_packed_depth_stencil and/or
215 // GL_GOOGLE_depth_texture. 258 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
216 // NOTE: GL_OES_depth_texture requires support for depth 259 //
217 // cubemaps. GL_ARB_depth_texture requires other features that 260 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
218 // GL_OES_packed_depth_stencil does not provide. Therefore we made up 261 // GL_ARB_depth_texture requires other features that
219 // GL_GOOGLE_depth_texture. 262 // GL_OES_packed_depth_stencil does not provide.
263 //
264 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
265 //
266 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
267 // get rid of it.
268 //
220 bool enable_depth_texture = false; 269 bool enable_depth_texture = false;
221 if (ext.Desire("GL_GOOGLE_depth_texture") && 270 if (ext.Desire("GL_GOOGLE_depth_texture") ||
222 (ext.Have("GL_ARB_depth_texture") || 271 ext.Desire("GL_CHROMIUM_depth_texture")) {
223 ext.Have("GL_OES_depth_texture"))) { 272 if (ext.Have("GL_ARB_depth_texture") ||
224 enable_depth_texture = true; 273 ext.Have("GL_OES_depth_texture")) {
274 enable_depth_texture = true;
275 }
276
277 if (ext.Have("GL_ANGLE_depth_texture")) {
apatrick_chromium 2012/06/07 22:11:36 This if can be combined with the one above.
greggman 2012/06/07 22:53:31 Done.
278 enable_depth_texture = true;
279 }
280 }
281
282 if (enable_depth_texture) {
283 AddExtensionString("GL_CHROMIUM_depth_texture");
225 AddExtensionString("GL_GOOGLE_depth_texture"); 284 AddExtensionString("GL_GOOGLE_depth_texture");
285 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT);
286 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT);
226 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT); 287 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
227 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT); 288 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
228 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT); 289 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
229 validators_.pixel_type.AddValue(GL_UNSIGNED_INT); 290 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
230 } 291 }
231 // TODO(gman): Add depth types fo ElementsPerGroup and BytesPerElement
232 292
233 if (ext.Desire("GL_OES_packed_depth_stencil") && 293 if (ext.Desire("GL_OES_packed_depth_stencil") &&
234 (ext.Have("GL_EXT_packed_depth_stencil") || 294 (ext.Have("GL_EXT_packed_depth_stencil") ||
235 ext.Have("GL_OES_packed_depth_stencil"))) { 295 ext.Have("GL_OES_packed_depth_stencil"))) {
236 AddExtensionString("GL_OES_packed_depth_stencil"); 296 AddExtensionString("GL_OES_packed_depth_stencil");
237 if (enable_depth_texture) { 297 if (enable_depth_texture) {
298 texture_format_validators_[GL_DEPTH_STENCIL].AddValue(
299 GL_UNSIGNED_INT_24_8);
238 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 300 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
239 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 301 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
240 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 302 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
241 } 303 }
242 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 304 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
243 } 305 }
244 306
245 bool enable_texture_format_bgra8888 = false; 307 bool enable_texture_format_bgra8888 = false;
246 bool enable_read_format_bgra = false; 308 bool enable_read_format_bgra = false;
247 // Check if we should allow GL_EXT_texture_format_BGRA8888 309 // Check if we should allow GL_EXT_texture_format_BGRA8888
(...skipping 10 matching lines...) Expand all
258 } 320 }
259 321
260 if (ext.Desire("GL_EXT_read_format_bgra") && 322 if (ext.Desire("GL_EXT_read_format_bgra") &&
261 (ext.Have("GL_EXT_read_format_bgra") || 323 (ext.Have("GL_EXT_read_format_bgra") ||
262 ext.Have("GL_EXT_bgra"))) { 324 ext.Have("GL_EXT_bgra"))) {
263 enable_read_format_bgra = true; 325 enable_read_format_bgra = true;
264 } 326 }
265 327
266 if (enable_texture_format_bgra8888) { 328 if (enable_texture_format_bgra8888) {
267 AddExtensionString("GL_EXT_texture_format_BGRA8888"); 329 AddExtensionString("GL_EXT_texture_format_BGRA8888");
330 texture_format_validators_[GL_BGRA_EXT].AddValue(GL_UNSIGNED_BYTE);
268 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); 331 validators_.texture_internal_format.AddValue(GL_BGRA_EXT);
269 validators_.texture_format.AddValue(GL_BGRA_EXT); 332 validators_.texture_format.AddValue(GL_BGRA_EXT);
270 } 333 }
271 334
272 if (enable_read_format_bgra) { 335 if (enable_read_format_bgra) {
273 AddExtensionString("GL_EXT_read_format_bgra"); 336 AddExtensionString("GL_EXT_read_format_bgra");
274 validators_.read_pixel_format.AddValue(GL_BGRA_EXT); 337 validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
275 } 338 }
276 339
277 if (ext.Desire("GL_OES_rgb8_rgba8")) { 340 if (ext.Desire("GL_OES_rgb8_rgba8")) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 enable_texture_half_float = true; 384 enable_texture_half_float = true;
322 if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") || 385 if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") ||
323 (have_arb_texture_float && 386 (have_arb_texture_float &&
324 ext.Desire("GL_OES_texture_half_float_linear"))) { 387 ext.Desire("GL_OES_texture_half_float_linear"))) {
325 enable_texture_half_float_linear = true; 388 enable_texture_half_float_linear = true;
326 } 389 }
327 } 390 }
328 } 391 }
329 392
330 if (enable_texture_float) { 393 if (enable_texture_float) {
394 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT);
395 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT);
396 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT);
397 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT);
398 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_FLOAT);
331 validators_.pixel_type.AddValue(GL_FLOAT); 399 validators_.pixel_type.AddValue(GL_FLOAT);
400 validators_.read_pixel_type.AddValue(GL_FLOAT);
332 AddExtensionString("GL_OES_texture_float"); 401 AddExtensionString("GL_OES_texture_float");
333 if (enable_texture_float_linear) { 402 if (enable_texture_float_linear) {
334 AddExtensionString("GL_OES_texture_float_linear"); 403 AddExtensionString("GL_OES_texture_float_linear");
335 } 404 }
336 } 405 }
337 406
338 if (enable_texture_half_float) { 407 if (enable_texture_half_float) {
408 texture_format_validators_[GL_ALPHA].AddValue(GL_HALF_FLOAT_OES);
409 texture_format_validators_[GL_RGB].AddValue(GL_HALF_FLOAT_OES);
410 texture_format_validators_[GL_RGBA].AddValue(GL_HALF_FLOAT_OES);
411 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES);
412 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
339 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 413 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
414 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
340 AddExtensionString("GL_OES_texture_half_float"); 415 AddExtensionString("GL_OES_texture_half_float");
341 if (enable_texture_half_float_linear) { 416 if (enable_texture_half_float_linear) {
342 AddExtensionString("GL_OES_texture_half_float_linear"); 417 AddExtensionString("GL_OES_texture_half_float_linear");
343 } 418 }
344 } 419 }
345 420
346 // Check for multisample support 421 // Check for multisample support
347 if (!disallowed_features_.multisampling && 422 if (!disallowed_features_.multisampling &&
348 ext.Desire("GL_CHROMIUM_framebuffer_multisample") && 423 ext.Desire("GL_CHROMIUM_framebuffer_multisample") &&
349 (ext.Have("GL_EXT_framebuffer_multisample") || 424 (ext.Have("GL_EXT_framebuffer_multisample") ||
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (extensions_.find(str) == std::string::npos) { 582 if (extensions_.find(str) == std::string::npos) {
508 extensions_ += (extensions_.empty() ? "" : " ") + str; 583 extensions_ += (extensions_.empty() ? "" : " ") + str;
509 } 584 }
510 } 585 }
511 586
512 FeatureInfo::~FeatureInfo() { 587 FeatureInfo::~FeatureInfo() {
513 } 588 }
514 589
515 } // namespace gles2 590 } // namespace gles2
516 } // namespace gpu 591 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698