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

Side by Side Diff: src/gpu/gl/debug/GrGLCreateDebugInterface.cpp

Issue 243413002: Add support for glMapBufferRange. Use glMapBufferRange and glMapBufferSubData. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase to tot Created 6 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
« no previous file with comments | « src/gpu/gl/debug/GrBufferObj.h ('k') | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2012 Google Inc. 3 * Copyright 2012 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "gl/GrGLInterface.h" 10 #include "gl/GrGLInterface.h"
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 GrBufferObj, 615 GrBufferObj,
616 GrDebugGL::kBuffer_ObjTypes); 616 GrDebugGL::kBuffer_ObjTypes);
617 GrAlwaysAssert(buffer); 617 GrAlwaysAssert(buffer);
618 618
619 GrAlwaysAssert(!buffer->getDeleted()); 619 GrAlwaysAssert(!buffer->getDeleted());
620 buffer->deleteAction(); 620 buffer->deleteAction();
621 } 621 }
622 } 622 }
623 623
624 // map a buffer to the caller's address space 624 // map a buffer to the caller's address space
625 GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) { 625 GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBufferRange(GrGLenum target, GrGLintptr offset,
626 626 GrGLsizeiptr length, GrGLbit field access) {
627 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || 627 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
628 GR_GL_ELEMENT_ARRAY_BUFFER == target); 628 GR_GL_ELEMENT_ARRAY_BUFFER == target);
629 // GR_GL_READ_ONLY == access || || GR_GL_READ_WRIT == access); 629
630 GrAlwaysAssert(GR_GL_WRITE_ONLY == access); 630 // We only expect read access and we expect that the buffer or range is alwa ys invalidated.
631 GrAlwaysAssert(!SkToBool(GR_GL_MAP_READ_BIT & access));
632 GrAlwaysAssert((GR_GL_MAP_INVALIDATE_BUFFER_BIT | GR_GL_MAP_INVALIDATE_RANGE _BIT) & access);
631 633
632 GrBufferObj *buffer = NULL; 634 GrBufferObj *buffer = NULL;
633 switch (target) { 635 switch (target) {
634 case GR_GL_ARRAY_BUFFER: 636 case GR_GL_ARRAY_BUFFER:
635 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 637 buffer = GrDebugGL::getInstance()->getArrayBuffer();
636 break; 638 break;
637 case GR_GL_ELEMENT_ARRAY_BUFFER: 639 case GR_GL_ELEMENT_ARRAY_BUFFER:
638 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 640 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
639 break; 641 break;
640 default: 642 default:
643 SkFAIL("Unexpected target to glMapBufferRange");
644 break;
645 }
646
647 if (NULL != buffer) {
648 GrAlwaysAssert(offset >= 0 && offset + length <= buffer->getSize());
649 GrAlwaysAssert(!buffer->getMapped());
650 buffer->setMapped(offset, length);
651 return buffer->getDataPtr() + offset;
652 }
653
654 GrAlwaysAssert(false);
655 return NULL; // no buffer bound to the target
656 }
657
658 GrGLvoid* GR_GL_FUNCTION_TYPE debugGLMapBuffer(GrGLenum target, GrGLenum access) {
659 GrAlwaysAssert(GR_GL_WRITE_ONLY == access);
660
661 GrBufferObj *buffer = NULL;
662 switch (target) {
663 case GR_GL_ARRAY_BUFFER:
664 buffer = GrDebugGL::getInstance()->getArrayBuffer();
665 break;
666 case GR_GL_ELEMENT_ARRAY_BUFFER:
667 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
668 break;
669 default:
641 SkFAIL("Unexpected target to glMapBuffer"); 670 SkFAIL("Unexpected target to glMapBuffer");
642 break; 671 break;
643 } 672 }
644 673
645 if (buffer) { 674 return debugGLMapBufferRange(target, 0, buffer->getSize(),
646 GrAlwaysAssert(!buffer->getMapped()); 675 GR_GL_MAP_WRITE_BIT | GR_GL_MAP_INVALIDATE_BUFF ER_BIT);
647 buffer->setMapped();
648 return buffer->getDataPtr();
649 }
650
651 GrAlwaysAssert(false);
652 return NULL; // no buffer bound to the target
653 } 676 }
654 677
655 // remove a buffer from the caller's address space 678 // remove a buffer from the caller's address space
656 // TODO: check if the "access" method from "glMapBuffer" was honored 679 // TODO: check if the "access" method from "glMapBuffer" was honored
657 GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) { 680 GrGLboolean GR_GL_FUNCTION_TYPE debugGLUnmapBuffer(GrGLenum target) {
658 681
659 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || 682 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
660 GR_GL_ELEMENT_ARRAY_BUFFER == target); 683 GR_GL_ELEMENT_ARRAY_BUFFER == target);
661 684
662 GrBufferObj *buffer = NULL; 685 GrBufferObj *buffer = NULL;
663 switch (target) { 686 switch (target) {
664 case GR_GL_ARRAY_BUFFER: 687 case GR_GL_ARRAY_BUFFER:
665 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 688 buffer = GrDebugGL::getInstance()->getArrayBuffer();
666 break; 689 break;
667 case GR_GL_ELEMENT_ARRAY_BUFFER: 690 case GR_GL_ELEMENT_ARRAY_BUFFER:
668 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 691 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
669 break; 692 break;
670 default: 693 default:
671 SkFAIL("Unexpected target to glUnmapBuffer"); 694 SkFAIL("Unexpected target to glUnmapBuffer");
672 break; 695 break;
673 } 696 }
674 697
675 if (buffer) { 698 if (NULL != buffer) {
676 GrAlwaysAssert(buffer->getMapped()); 699 GrAlwaysAssert(buffer->getMapped());
677 buffer->resetMapped(); 700 buffer->resetMapped();
678 return GR_GL_TRUE; 701 return GR_GL_TRUE;
679 } 702 }
680 703
681 GrAlwaysAssert(false); 704 GrAlwaysAssert(false);
682 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION; 705 return GR_GL_FALSE; // GR_GL_INVALID_OPERATION;
683 } 706 }
684 707
708 GrGLvoid GR_GL_FUNCTION_TYPE debugGLFlushMappedBufferRange(GrGLenum target,
709 GrGLintptr offset,
710 GrGLsizeiptr length) {
711 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
712 GR_GL_ELEMENT_ARRAY_BUFFER == target);
713
714 GrBufferObj *buffer = NULL;
715 switch (target) {
716 case GR_GL_ARRAY_BUFFER:
717 buffer = GrDebugGL::getInstance()->getArrayBuffer();
718 break;
719 case GR_GL_ELEMENT_ARRAY_BUFFER:
720 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
721 break;
722 default:
723 SkFAIL("Unexpected target to glUnmapBuffer");
724 break;
725 }
726
727 if (NULL != buffer) {
728 GrAlwaysAssert(buffer->getMapped());
729 GrAlwaysAssert(offset >= 0 && (offset + length) <= buffer->getMappedLeng th());
730 } else {
731 GrAlwaysAssert(false);
732 }
733 }
734
735
685 GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target, 736 GrGLvoid GR_GL_FUNCTION_TYPE debugGLGetBufferParameteriv(GrGLenum target,
686 GrGLenum value, 737 GrGLenum value,
687 GrGLint* params) { 738 GrGLint* params) {
688 739
689 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target || 740 GrAlwaysAssert(GR_GL_ARRAY_BUFFER == target ||
690 GR_GL_ELEMENT_ARRAY_BUFFER == target); 741 GR_GL_ELEMENT_ARRAY_BUFFER == target);
691 GrAlwaysAssert(GR_GL_BUFFER_SIZE == value || 742 GrAlwaysAssert(GR_GL_BUFFER_SIZE == value ||
692 GR_GL_BUFFER_USAGE == value); 743 GR_GL_BUFFER_USAGE == value);
693 744
694 GrBufferObj *buffer = NULL; 745 GrBufferObj *buffer = NULL;
695 switch (target) { 746 switch (target) {
696 case GR_GL_ARRAY_BUFFER: 747 case GR_GL_ARRAY_BUFFER:
697 buffer = GrDebugGL::getInstance()->getArrayBuffer(); 748 buffer = GrDebugGL::getInstance()->getArrayBuffer();
698 break; 749 break;
699 case GR_GL_ELEMENT_ARRAY_BUFFER: 750 case GR_GL_ELEMENT_ARRAY_BUFFER:
700 buffer = GrDebugGL::getInstance()->getElementArrayBuffer(); 751 buffer = GrDebugGL::getInstance()->getElementArrayBuffer();
701 break; 752 break;
702 } 753 }
703 754
704 GrAlwaysAssert(buffer); 755 GrAlwaysAssert(buffer);
705 756
706 switch (value) { 757 switch (value) {
707 case GR_GL_BUFFER_MAPPED: 758 case GR_GL_BUFFER_MAPPED:
708 *params = GR_GL_FALSE; 759 *params = GR_GL_FALSE;
709 if (buffer) 760 if (NULL != buffer)
710 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE; 761 *params = buffer->getMapped() ? GR_GL_TRUE : GR_GL_FALSE;
711 break; 762 break;
712 case GR_GL_BUFFER_SIZE: 763 case GR_GL_BUFFER_SIZE:
713 *params = 0; 764 *params = 0;
714 if (buffer) 765 if (NULL != buffer)
715 *params = SkToInt(buffer->getSize()); 766 *params = SkToInt(buffer->getSize());
716 break; 767 break;
717 case GR_GL_BUFFER_USAGE: 768 case GR_GL_BUFFER_USAGE:
718 *params = GR_GL_STATIC_DRAW; 769 *params = GR_GL_STATIC_DRAW;
719 if (buffer) 770 if (NULL != buffer)
720 *params = buffer->getUsage(); 771 *params = buffer->getUsage();
721 break; 772 break;
722 default: 773 default:
723 SkFAIL("Unexpected value to glGetBufferParamateriv"); 774 SkFAIL("Unexpected value to glGetBufferParamateriv");
724 break; 775 break;
725 } 776 }
726 }; 777 };
727 } // end of namespace 778 } // end of namespace
728 779
729 //////////////////////////////////////////////////////////////////////////////// 780 ////////////////////////////////////////////////////////////////////////////////
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray; 870 functions->fDisableVertexAttribArray = noOpGLDisableVertexAttribArray;
820 functions->fDrawArrays = noOpGLDrawArrays; 871 functions->fDrawArrays = noOpGLDrawArrays;
821 functions->fDrawBuffer = noOpGLDrawBuffer; 872 functions->fDrawBuffer = noOpGLDrawBuffer;
822 functions->fDrawBuffers = noOpGLDrawBuffers; 873 functions->fDrawBuffers = noOpGLDrawBuffers;
823 functions->fDrawElements = noOpGLDrawElements; 874 functions->fDrawElements = noOpGLDrawElements;
824 functions->fEnable = noOpGLEnable; 875 functions->fEnable = noOpGLEnable;
825 functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray; 876 functions->fEnableVertexAttribArray = noOpGLEnableVertexAttribArray;
826 functions->fEndQuery = noOpGLEndQuery; 877 functions->fEndQuery = noOpGLEndQuery;
827 functions->fFinish = noOpGLFinish; 878 functions->fFinish = noOpGLFinish;
828 functions->fFlush = noOpGLFlush; 879 functions->fFlush = noOpGLFlush;
880 functions->fFlushMappedBufferRange = debugGLFlushMappedBufferRange;
829 functions->fFrontFace = noOpGLFrontFace; 881 functions->fFrontFace = noOpGLFrontFace;
830 functions->fGenerateMipmap = debugGLGenerateMipmap; 882 functions->fGenerateMipmap = debugGLGenerateMipmap;
831 functions->fGenBuffers = debugGLGenBuffers; 883 functions->fGenBuffers = debugGLGenBuffers;
832 functions->fGenQueries = noOpGLGenIds; 884 functions->fGenQueries = noOpGLGenIds;
833 functions->fGenTextures = debugGLGenTextures; 885 functions->fGenTextures = debugGLGenTextures;
834 functions->fGetBufferParameteriv = debugGLGetBufferParameteriv; 886 functions->fGetBufferParameteriv = debugGLGetBufferParameteriv;
835 functions->fGetError = noOpGLGetError; 887 functions->fGetError = noOpGLGetError;
836 functions->fGetIntegerv = noOpGLGetIntegerv; 888 functions->fGetIntegerv = noOpGLGetIntegerv;
837 functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v; 889 functions->fGetQueryObjecti64v = noOpGLGetQueryObjecti64v;
838 functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv; 890 functions->fGetQueryObjectiv = noOpGLGetQueryObjectiv;
839 functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v; 891 functions->fGetQueryObjectui64v = noOpGLGetQueryObjectui64v;
840 functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv; 892 functions->fGetQueryObjectuiv = noOpGLGetQueryObjectuiv;
841 functions->fGetQueryiv = noOpGLGetQueryiv; 893 functions->fGetQueryiv = noOpGLGetQueryiv;
842 functions->fGetProgramInfoLog = noOpGLGetInfoLog; 894 functions->fGetProgramInfoLog = noOpGLGetInfoLog;
843 functions->fGetProgramiv = noOpGLGetShaderOrProgramiv; 895 functions->fGetProgramiv = noOpGLGetShaderOrProgramiv;
844 functions->fGetShaderInfoLog = noOpGLGetInfoLog; 896 functions->fGetShaderInfoLog = noOpGLGetInfoLog;
845 functions->fGetShaderiv = noOpGLGetShaderOrProgramiv; 897 functions->fGetShaderiv = noOpGLGetShaderOrProgramiv;
846 functions->fGetString = noOpGLGetString; 898 functions->fGetString = noOpGLGetString;
847 functions->fGetStringi = noOpGLGetStringi; 899 functions->fGetStringi = noOpGLGetStringi;
848 functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv; 900 functions->fGetTexLevelParameteriv = noOpGLGetTexLevelParameteriv;
849 functions->fGetUniformLocation = noOpGLGetUniformLocation; 901 functions->fGetUniformLocation = noOpGLGetUniformLocation;
850 functions->fGenVertexArrays = debugGLGenVertexArrays; 902 functions->fGenVertexArrays = debugGLGenVertexArrays;
851 functions->fLineWidth = noOpGLLineWidth; 903 functions->fLineWidth = noOpGLLineWidth;
852 functions->fLinkProgram = noOpGLLinkProgram; 904 functions->fLinkProgram = noOpGLLinkProgram;
905 functions->fMapBuffer = debugGLMapBuffer;
906 functions->fMapBufferRange = debugGLMapBufferRange;
853 functions->fPixelStorei = debugGLPixelStorei; 907 functions->fPixelStorei = debugGLPixelStorei;
854 functions->fQueryCounter = noOpGLQueryCounter; 908 functions->fQueryCounter = noOpGLQueryCounter;
855 functions->fReadBuffer = noOpGLReadBuffer; 909 functions->fReadBuffer = noOpGLReadBuffer;
856 functions->fReadPixels = debugGLReadPixels; 910 functions->fReadPixels = debugGLReadPixels;
857 functions->fScissor = noOpGLScissor; 911 functions->fScissor = noOpGLScissor;
858 functions->fShaderSource = noOpGLShaderSource; 912 functions->fShaderSource = noOpGLShaderSource;
859 functions->fStencilFunc = noOpGLStencilFunc; 913 functions->fStencilFunc = noOpGLStencilFunc;
860 functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate; 914 functions->fStencilFuncSeparate = noOpGLStencilFuncSeparate;
861 functions->fStencilMask = noOpGLStencilMask; 915 functions->fStencilMask = noOpGLStencilMask;
862 functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate; 916 functions->fStencilMaskSeparate = noOpGLStencilMaskSeparate;
(...skipping 17 matching lines...) Expand all
880 functions->fUniform3i = noOpGLUniform3i; 934 functions->fUniform3i = noOpGLUniform3i;
881 functions->fUniform3fv = noOpGLUniform3fv; 935 functions->fUniform3fv = noOpGLUniform3fv;
882 functions->fUniform3iv = noOpGLUniform3iv; 936 functions->fUniform3iv = noOpGLUniform3iv;
883 functions->fUniform4f = noOpGLUniform4f; 937 functions->fUniform4f = noOpGLUniform4f;
884 functions->fUniform4i = noOpGLUniform4i; 938 functions->fUniform4i = noOpGLUniform4i;
885 functions->fUniform4fv = noOpGLUniform4fv; 939 functions->fUniform4fv = noOpGLUniform4fv;
886 functions->fUniform4iv = noOpGLUniform4iv; 940 functions->fUniform4iv = noOpGLUniform4iv;
887 functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv; 941 functions->fUniformMatrix2fv = noOpGLUniformMatrix2fv;
888 functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv; 942 functions->fUniformMatrix3fv = noOpGLUniformMatrix3fv;
889 functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv; 943 functions->fUniformMatrix4fv = noOpGLUniformMatrix4fv;
944 functions->fUnmapBuffer = debugGLUnmapBuffer;
890 functions->fUseProgram = debugGLUseProgram; 945 functions->fUseProgram = debugGLUseProgram;
891 functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv; 946 functions->fVertexAttrib4fv = noOpGLVertexAttrib4fv;
892 functions->fVertexAttribPointer = noOpGLVertexAttribPointer; 947 functions->fVertexAttribPointer = noOpGLVertexAttribPointer;
893 functions->fViewport = noOpGLViewport; 948 functions->fViewport = noOpGLViewport;
894 functions->fBindFramebuffer = debugGLBindFramebuffer; 949 functions->fBindFramebuffer = debugGLBindFramebuffer;
895 functions->fBindRenderbuffer = debugGLBindRenderbuffer; 950 functions->fBindRenderbuffer = debugGLBindRenderbuffer;
896 functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus; 951 functions->fCheckFramebufferStatus = noOpGLCheckFramebufferStatus;
897 functions->fDeleteFramebuffers = debugGLDeleteFramebuffers; 952 functions->fDeleteFramebuffers = debugGLDeleteFramebuffers;
898 functions->fDeleteRenderbuffers = debugGLDeleteRenderbuffers; 953 functions->fDeleteRenderbuffers = debugGLDeleteRenderbuffers;
899 functions->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer; 954 functions->fFramebufferRenderbuffer = debugGLFramebufferRenderbuffer;
900 functions->fFramebufferTexture2D = debugGLFramebufferTexture2D; 955 functions->fFramebufferTexture2D = debugGLFramebufferTexture2D;
901 functions->fGenFramebuffers = debugGLGenFramebuffers; 956 functions->fGenFramebuffers = debugGLGenFramebuffers;
902 functions->fGenRenderbuffers = debugGLGenRenderbuffers; 957 functions->fGenRenderbuffers = debugGLGenRenderbuffers;
903 functions->fGetFramebufferAttachmentParameteriv = 958 functions->fGetFramebufferAttachmentParameteriv =
904 noOpGLGetFramebufferAttachmentParameteriv; 959 noOpGLGetFramebufferAttachmentParameteriv;
905 functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv; 960 functions->fGetRenderbufferParameteriv = noOpGLGetRenderbufferParameteriv;
906 functions->fRenderbufferStorage = noOpGLRenderbufferStorage; 961 functions->fRenderbufferStorage = noOpGLRenderbufferStorage;
907 functions->fRenderbufferStorageMultisample = 962 functions->fRenderbufferStorageMultisample =
908 noOpGLRenderbufferStorageMultisample; 963 noOpGLRenderbufferStorageMultisample;
909 functions->fBlitFramebuffer = noOpGLBlitFramebuffer; 964 functions->fBlitFramebuffer = noOpGLBlitFramebuffer;
910 functions->fResolveMultisampleFramebuffer = 965 functions->fResolveMultisampleFramebuffer =
911 noOpGLResolveMultisampleFramebuffer; 966 noOpGLResolveMultisampleFramebuffer;
912 functions->fMapBuffer = debugGLMapBuffer;
913 functions->fMatrixLoadf = noOpGLMatrixLoadf; 967 functions->fMatrixLoadf = noOpGLMatrixLoadf;
914 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity; 968 functions->fMatrixLoadIdentity = noOpGLMatrixLoadIdentity;
915 functions->fUnmapBuffer = debugGLUnmapBuffer; 969
916 functions->fBindFragDataLocationIndexed = 970 functions->fBindFragDataLocationIndexed =
917 noOpGLBindFragDataLocationIndexed; 971 noOpGLBindFragDataLocationIndexed;
918 972
919 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi, 973 interface->fExtensions.init(kGL_GrGLStandard, functions->fGetString, functio ns->fGetStringi,
920 functions->fGetIntegerv); 974 functions->fGetIntegerv);
921 975
922 return interface; 976 return interface;
923 } 977 }
OLDNEW
« no previous file with comments | « src/gpu/gl/debug/GrBufferObj.h ('k') | src/gpu/gl/iOS/GrGLCreateNativeInterface_iOS.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698