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

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGL2RenderingContextBase.cpp

Issue 2197893003: Relax multi-sampling for floating-point color renderbuffers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/webgl/WebGL2RenderingContextBase.h" 5 #include "modules/webgl/WebGL2RenderingContextBase.h"
6 6
7 #include "bindings/modules/v8/WebGLAny.h" 7 #include "bindings/modules/v8/WebGLAny.h"
8 #include "core/frame/ImageBitmap.h" 8 #include "core/frame/ImageBitmap.h"
9 #include "core/html/HTMLCanvasElement.h" 9 #include "core/html/HTMLCanvasElement.h"
10 #include "core/html/HTMLImageElement.h" 10 #include "core/html/HTMLImageElement.h"
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname) 333 ScriptValue WebGL2RenderingContextBase::getInternalformatParameter(ScriptState* scriptState, GLenum target, GLenum internalformat, GLenum pname)
334 { 334 {
335 if (isContextLost()) 335 if (isContextLost())
336 return ScriptValue::createNull(scriptState); 336 return ScriptValue::createNull(scriptState);
337 337
338 if (target != GL_RENDERBUFFER) { 338 if (target != GL_RENDERBUFFER) {
339 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d target"); 339 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d target");
340 return ScriptValue::createNull(scriptState); 340 return ScriptValue::createNull(scriptState);
341 } 341 }
342 342
343 bool floatType = false;
344 343
345 switch (internalformat) { 344 switch (internalformat) {
346 // Renderbuffer doesn't support unsized internal formats, 345 // Renderbuffer doesn't support unsized internal formats,
347 // though GL_RGB and GL_RGBA are color-renderable. 346 // though GL_RGB and GL_RGBA are color-renderable.
348 case GL_RGB: 347 case GL_RGB:
349 case GL_RGBA: 348 case GL_RGBA:
350 // Multisampling is not supported for signed and unsigned integer internal f ormats. 349 // Multisampling is not supported for signed and unsigned integer internal f ormats.
351 case GL_R8UI: 350 case GL_R8UI:
352 case GL_R8I: 351 case GL_R8I:
353 case GL_R16UI: 352 case GL_R16UI:
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 case GL_RG16F: 387 case GL_RG16F:
389 case GL_RGBA16F: 388 case GL_RGBA16F:
390 case GL_R32F: 389 case GL_R32F:
391 case GL_RG32F: 390 case GL_RG32F:
392 case GL_RGBA32F: 391 case GL_RGBA32F:
393 case GL_R11F_G11F_B10F: 392 case GL_R11F_G11F_B10F:
394 if (!extensionEnabled(EXTColorBufferFloatName)) { 393 if (!extensionEnabled(EXTColorBufferFloatName)) {
395 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "in valid internalformat when EXT_color_buffer_float is not enabled"); 394 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "in valid internalformat when EXT_color_buffer_float is not enabled");
396 return ScriptValue::createNull(scriptState); 395 return ScriptValue::createNull(scriptState);
397 } 396 }
398 floatType = true;
399 break; 397 break;
400 default: 398 default:
401 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d internalformat"); 399 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d internalformat");
402 return ScriptValue::createNull(scriptState); 400 return ScriptValue::createNull(scriptState);
403 } 401 }
404 402
405 switch (pname) { 403 switch (pname) {
406 case GL_SAMPLES: 404 case GL_SAMPLES:
407 { 405 {
408 std::unique_ptr<GLint[]> values; 406 std::unique_ptr<GLint[]> values;
409 GLint length = -1; 407 GLint length = -1;
410 if (!floatType) { 408 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_SAMP LE_COUNTS, 1, &length);
411 contextGL()->GetInternalformativ(target, internalformat, GL_NUM_ SAMPLE_COUNTS, 1, &length); 409 if (length <= 0)
412 if (length <= 0) 410 return WebGLAny(scriptState, DOMInt32Array::create(0));
413 return WebGLAny(scriptState, DOMInt32Array::create(0));
414 411
415 values = wrapArrayUnique(new GLint[length]); 412 values = wrapArrayUnique(new GLint[length]);
416 for (GLint ii = 0; ii < length; ++ii) 413 for (GLint ii = 0; ii < length; ++ii)
417 values[ii] = 0; 414 values[ii] = 0;
418 contextGL()->GetInternalformativ(target, internalformat, GL_SAMP LES, length, values.get()); 415 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, length, values.get());
419 } else {
420 length = 1;
421 values = wrapArrayUnique(new GLint[1]);
422 values[0] = 1;
423 }
424 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth)); 416 return WebGLAny(scriptState, DOMInt32Array::create(values.get(), len gth));
425 } 417 }
426 default: 418 default:
427 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name"); 419 synthesizeGLError(GL_INVALID_ENUM, "getInternalformatParameter", "invali d parameter name");
428 return ScriptValue::createNull(scriptState); 420 return ScriptValue::createNull(scriptState);
429 } 421 }
430 } 422 }
431 423
432 bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functi onName, GLenum target, Vector<GLenum>& attachments) 424 bool WebGL2RenderingContextBase::checkAndTranslateAttachments(const char* functi onName, GLenum target, Vector<GLenum>& attachments)
433 { 425 {
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 { 618 {
627 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer); 619 ScopedDrawingBufferBinder binder(drawingBuffer(), framebuffer);
628 contextGL()->ReadPixels(x, y, width, height, format, type, reinterpret_c ast<void*>(offset)); 620 contextGL()->ReadPixels(x, y, width, height, format, type, reinterpret_c ast<void*>(offset));
629 } 621 }
630 } 622 }
631 623
632 void WebGL2RenderingContextBase::renderbufferStorageImpl( 624 void WebGL2RenderingContextBase::renderbufferStorageImpl(
633 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height, 625 GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsize i height,
634 const char* functionName) 626 const char* functionName)
635 { 627 {
628 bool floatType = false;
636 switch (internalformat) { 629 switch (internalformat) {
637 case GL_R8UI: 630 case GL_R8UI:
638 case GL_R8I: 631 case GL_R8I:
639 case GL_R16UI: 632 case GL_R16UI:
640 case GL_R16I: 633 case GL_R16I:
641 case GL_R32UI: 634 case GL_R32UI:
642 case GL_R32I: 635 case GL_R32I:
643 case GL_RG8UI: 636 case GL_RG8UI:
644 case GL_RG8I: 637 case GL_RG8I:
645 case GL_RG16UI: 638 case GL_RG16UI:
646 case GL_RG16I: 639 case GL_RG16I:
647 case GL_RG32UI: 640 case GL_RG32UI:
648 case GL_RG32I: 641 case GL_RG32I:
649 case GL_RGBA8UI: 642 case GL_RGBA8UI:
650 case GL_RGBA8I: 643 case GL_RGBA8I:
651 case GL_RGB10_A2UI: 644 case GL_RGB10_A2UI:
652 case GL_RGBA16UI: 645 case GL_RGBA16UI:
653 case GL_RGBA16I: 646 case GL_RGBA16I:
654 case GL_RGBA32UI: 647 case GL_RGBA32UI:
655 case GL_RGBA32I: 648 case GL_RGBA32I:
656 if (samples > 0) { 649 if (samples > 0) {
657 synthesizeGLError(GL_INVALID_OPERATION, functionName, 650 synthesizeGLError(GL_INVALID_OPERATION, functionName,
658 "for integer formats, samples > 0"); 651 "for integer formats, samples > 0");
659 return; 652 return;
660 } 653 }
654 case GL_R16F:
655 case GL_RG16F:
656 case GL_RGBA16F:
657 case GL_R32F:
658 case GL_RG32F:
659 case GL_RGBA32F:
660 case GL_R11F_G11F_B10F:
661 floatType = true;
yunchao 2016/08/01 02:49:42 The fall-through code here will be executed for in
661 case GL_R8: 662 case GL_R8:
662 case GL_RG8: 663 case GL_RG8:
663 case GL_RGB8: 664 case GL_RGB8:
664 case GL_RGB565: 665 case GL_RGB565:
665 case GL_RGBA8: 666 case GL_RGBA8:
666 case GL_SRGB8_ALPHA8: 667 case GL_SRGB8_ALPHA8:
667 case GL_RGB5_A1: 668 case GL_RGB5_A1:
668 case GL_RGBA4: 669 case GL_RGBA4:
669 case GL_RGB10_A2: 670 case GL_RGB10_A2:
670 case GL_DEPTH_COMPONENT16: 671 case GL_DEPTH_COMPONENT16:
671 case GL_DEPTH_COMPONENT24: 672 case GL_DEPTH_COMPONENT24:
672 case GL_DEPTH_COMPONENT32F: 673 case GL_DEPTH_COMPONENT32F:
673 case GL_DEPTH24_STENCIL8: 674 case GL_DEPTH24_STENCIL8:
674 case GL_DEPTH32F_STENCIL8: 675 case GL_DEPTH32F_STENCIL8:
675 case GL_STENCIL_INDEX8: 676 case GL_STENCIL_INDEX8:
677 if (floatType && !extensionEnabled(EXTColorBufferFloatName)) {
678 synthesizeGLError(GL_INVALID_ENUM, functionName, "EXT_color_buffer_f loat not enabled");
679 return;
680 }
676 if (!samples) { 681 if (!samples) {
677 contextGL()->RenderbufferStorage(target, internalformat, width, heig ht); 682 contextGL()->RenderbufferStorage(target, internalformat, width, heig ht);
678 } else { 683 } else {
679 GLint maxNumberOfSamples = 0; 684 GLint maxNumberOfSamples = 0;
680 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples); 685 contextGL()->GetInternalformativ(target, internalformat, GL_SAMPLES, 1, &maxNumberOfSamples);
681 if (samples > maxNumberOfSamples) { 686 if (samples > maxNumberOfSamples) {
682 synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples o ut of range"); 687 synthesizeGLError(GL_INVALID_OPERATION, functionName, "samples o ut of range");
683 return; 688 return;
684 } 689 }
685 contextGL()->RenderbufferStorageMultisampleCHROMIUM( 690 contextGL()->RenderbufferStorageMultisampleCHROMIUM(
686 target, samples, internalformat, width, height); 691 target, samples, internalformat, width, height);
687 } 692 }
688 break; 693 break;
689 case GL_DEPTH_STENCIL: 694 case GL_DEPTH_STENCIL:
690 // To be WebGL 1 backward compatible. 695 // To be WebGL 1 backward compatible.
691 if (samples > 0) { 696 if (samples > 0) {
692 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalfo rmat"); 697 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalfo rmat");
693 return; 698 return;
694 } 699 }
695 contextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8, width, hei ght); 700 contextGL()->RenderbufferStorage(target, GL_DEPTH24_STENCIL8, width, hei ght);
696 break; 701 break;
697 case GL_R16F:
698 case GL_RG16F:
699 case GL_RGBA16F:
700 case GL_R32F:
701 case GL_RG32F:
702 case GL_RGBA32F:
703 case GL_R11F_G11F_B10F:
704 if (!extensionEnabled(EXTColorBufferFloatName)) {
705 synthesizeGLError(GL_INVALID_ENUM, functionName, "EXT_color_buffer_f loat not enabled");
706 return;
707 }
708 if (samples) {
709 synthesizeGLError(GL_INVALID_VALUE, functionName, "multisampled floa t buffers not supported");
710 return;
711 }
712 contextGL()->RenderbufferStorage(target, internalformat, width, height);
713 break;
714 default: 702 default:
715 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat "); 703 synthesizeGLError(GL_INVALID_ENUM, functionName, "invalid internalformat ");
716 return; 704 return;
717 } 705 }
718 m_renderbufferBinding->setInternalFormat(internalformat); 706 m_renderbufferBinding->setInternalFormat(internalformat);
719 m_renderbufferBinding->setSize(width, height); 707 m_renderbufferBinding->setSize(width, height);
720 } 708 }
721 709
722 void WebGL2RenderingContextBase::renderbufferStorageMultisample(GLenum target, G Lsizei samples, GLenum internalformat, GLsizei width, GLsizei height) 710 void WebGL2RenderingContextBase::renderbufferStorageMultisample(GLenum target, G Lsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
723 { 711 {
(...skipping 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after
3369 params.skipPixels = m_unpackSkipPixels; 3357 params.skipPixels = m_unpackSkipPixels;
3370 params.skipRows = m_unpackSkipRows; 3358 params.skipRows = m_unpackSkipRows;
3371 if (dimension == Tex3D) { 3359 if (dimension == Tex3D) {
3372 params.imageHeight = m_unpackImageHeight; 3360 params.imageHeight = m_unpackImageHeight;
3373 params.skipImages = m_unpackSkipImages; 3361 params.skipImages = m_unpackSkipImages;
3374 } 3362 }
3375 return params; 3363 return params;
3376 } 3364 }
3377 3365
3378 } // namespace blink 3366 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698