OLD | NEW |
---|---|
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 Loading... | |
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 | |
robertphillips
2014/05/02 12:57:30
NULL != ?
bsalomon
2014/05/02 14:44:22
Done.
| |
647 if (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; | |
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; |
(...skipping 12 matching lines...) Expand all Loading... | |
675 if (buffer) { | 698 if (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 | |
robertphillips
2014/05/02 12:57:30
NULL != ?
| |
727 if (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; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 Loading... | |
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 } |
OLD | NEW |