MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCL-CTS / ReadGLTexture

Function ReadGLTexture

test_common/gl/helpers.cpp:755–861  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

753}
754
755void * ReadGLTexture( GLenum glTarget, GLuint glTexture, GLuint glBuf, GLint width,
756 GLenum glFormat, GLenum glInternalFormat,
757 GLenum glType, ExplicitType typeToReadAs,
758 size_t outWidth, size_t outHeight )
759{
760 // Read results from the GL texture
761 glBindTexture(get_base_gl_target(glTarget), glTexture);
762
763 GLint realWidth, realHeight, realDepth;
764 glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_WIDTH, &realWidth );
765 glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_HEIGHT, &realHeight );
766 glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_DEPTH, &realDepth );
767
768 realDepth = (realDepth) ? realDepth : 1;
769
770 GLint realInternalFormat;
771 glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &realInternalFormat );
772
773#ifdef DEBUG
774 log_info( "- Reading back from GL: %d x %d : %s : %s : %s : %s (stored as %s)\n",
775 realWidth, realHeight,
776 GetGLTargetName( glTarget),
777 GetGLFormatName( glInternalFormat ),
778 GetGLFormatName( glFormat ),
779 GetGLTypeName( glType ),
780 GetGLFormatName( realInternalFormat ));
781#endif
782
783 GLenum readBackFormat;
784 switch(glFormat)
785 {
786 case GL_RGBA_INTEGER_EXT:
787 readBackFormat = GL_RGBA_INTEGER_EXT;
788 break;
789 case GL_DEPTH_COMPONENT:
790 readBackFormat = GL_DEPTH_COMPONENT;
791 break;
792 case GL_DEPTH_STENCIL:
793 readBackFormat = GL_DEPTH_STENCIL;
794 break;
795 default:
796 readBackFormat = GL_RGBA;
797 break;
798 }
799
800 GLenum readBackType;
801 switch (glType) {
802#ifdef __APPLE__
803 case GL_UNSIGNED_INT_8_8_8_8:
804 case GL_UNSIGNED_INT_8_8_8_8_REV:
805 readBackType = GL_UNSIGNED_BYTE;
806 break;
807#endif
808 case GL_HALF_FLOAT:
809 case GL_UNSIGNED_BYTE:
810 case GL_UNSIGNED_SHORT:
811 case GL_UNSIGNED_INT:
812 case GL_BYTE:

Callers 2

test_image_format_writeFunction · 0.50
test_image_format_writeFunction · 0.50

Calls 7

get_base_gl_targetFunction · 0.70
GetGLTargetNameFunction · 0.70
GetGLFormatNameFunction · 0.70
GetGLTypeNameFunction · 0.70
GetGLTypeSizeFunction · 0.70
GetGLTypeForExplicitTypeFunction · 0.70
DumpGLBufferFunction · 0.70

Tested by 2

test_image_format_writeFunction · 0.40
test_image_format_writeFunction · 0.40