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

Function test_image_format_write

test_conformance/gles/test_images_2D.cpp:491–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489
490
491int test_image_format_write( cl_context context, cl_command_queue queue,
492 size_t width, size_t height, GLenum target,
493 GLenum format, GLenum internalFormat,
494 GLenum glType, ExplicitType type, MTdata d )
495{
496 int error;
497
498 // Create the GL texture
499 glTextureWrapper glTexture;
500 void *tmp = CreateGLTexture2D( width, height, target, format, internalFormat, glType, type, &glTexture, &error, true, d );
501 BufferOwningPtr<char> inputBuffer(tmp);
502 if( error != 0 )
503 {
504 return error;
505 }
506
507 /* skip formats not supported by OpenGL */
508 if(!tmp)
509 {
510 return 0;
511 }
512
513 // Run and get the results
514 cl_image_format clFormat;
515 ExplicitType sourceType;
516 void *outSourceBuffer;
517 error = test_image_write( context, queue, target, glTexture, width, height, &clFormat, &sourceType, (void **)&outSourceBuffer, d );
518 if( error != 0 )
519 return error;
520
521 BufferOwningPtr<char> actualSource(outSourceBuffer);
522
523 log_info( "- Write [%4d x %4d] : GL Texture : %s : %s : %s => CL Image : %s : %s \n", (int)width, (int)height,
524 GetGLFormatName( format ), GetGLFormatName( internalFormat ), GetGLTypeName( glType),
525 GetChannelOrderName( clFormat.image_channel_order ), GetChannelTypeName( clFormat.image_channel_data_type ));
526
527 // Now read the results from the GL texture
528 ExplicitType readType = type;
529 BufferOwningPtr<char> glResults( ReadGLTexture( target, glTexture, format, internalFormat, glType, readType, width, height ) );
530
531 // We have to convert our input buffer to the returned type, so we can validate.
532 BufferOwningPtr<char> convertedGLResults( convert_to_expected( glResults, width * height, readType, sourceType ) );
533
534#ifdef GLES_DEBUG
535 log_info("- start read GL data -- \n");
536 DumpGLBuffer(glType, width, height, glResults);
537 log_info("- end read GL data -- \n");
538
539 log_info("- start converted data -- \n");
540 DumpGLBuffer(glType, width, height, convertedGLResults);
541 log_info("- end converted data -- \n");
542#endif
543
544 // Now we validate
545 int valid = 0;
546 if(convertedGLResults) {
547 if( sourceType == kFloat )
548 valid = validate_float_results( actualSource, convertedGLResults, width, height );

Callers 2

test_images_2D.cppFile · 0.70
test_images_write_cubeFunction · 0.70

Calls 9

GetChannelOrderNameFunction · 0.85
GetChannelTypeNameFunction · 0.85
get_explicit_type_sizeFunction · 0.85
test_image_writeFunction · 0.70
CreateGLTexture2DFunction · 0.50
GetGLFormatNameFunction · 0.50
GetGLTypeNameFunction · 0.50
ReadGLTextureFunction · 0.50
DumpGLBufferFunction · 0.50

Tested by

no test coverage detected