1 //
2 // Copyright (c) 2017 The Khronos Group Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //    http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 #ifndef _testBase_h
17 #define _testBase_h
18 
19 #include "harness/compat.h"
20 
21 #include <stdio.h>
22 #include <string.h>
23 #include <sys/types.h>
24 #include <sys/stat.h>
25 
26 #if !defined (__APPLE__)
27 #include <CL/cl.h>
28 #include "gl/gl_headers.h"
29 #include <CL/cl_gl.h>
30 #else
31 #include "gl/gl_headers.h"
32 #endif
33 
34 #include "harness/imageHelpers.h"
35 #include "harness/errorHelpers.h"
36 #include "harness/kernelHelpers.h"
37 #include "harness/threadTesting.h"
38 #include "harness/typeWrappers.h"
39 #include "harness/conversions.h"
40 #include "harness/mt19937.h"
41 
42 #include "gl/helpers.h"
43 
44 extern const char *get_kernel_suffix( cl_image_format *format );
45 extern const char *get_write_conversion( cl_image_format *format, ExplicitType type);
46 extern ExplicitType get_read_kernel_type( cl_image_format *format );
47 extern ExplicitType get_write_kernel_type( cl_image_format *format );
48 
49 extern char * convert_to_expected( void * inputBuffer, size_t numPixels, ExplicitType inType, ExplicitType outType, size_t channelNum, GLenum glDataType = 0);
50 extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum, size_t typeSize );
51 extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum, size_t typeSize );
52 extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum, size_t channelNum );
53 extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum, size_t channelNum );
54 extern int validate_float_results_rgb_101010( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum );
55 extern int validate_float_results_rgb_101010( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum );
56 
57 extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type, GLuint expected_gl_name,
58                              GLenum expected_cl_gl_texture_target, GLint expected_cl_gl_mipmap_level);
59 
60 extern bool CheckGLIntegerExtensionSupport();
61 
62 #endif // _testBase_h
63 
64 
65 
66