mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-19 06:09:01 +00:00
[NFC] clang-format gl (#1612)
Add some clang-format off/on comments to keep kernel code readable. Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
committed by
GitHub
parent
2318cedb21
commit
f46cca0f8f
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,17 +18,19 @@
|
|||||||
|
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
size_t width;
|
{
|
||||||
size_t height;
|
size_t width;
|
||||||
size_t depth;
|
size_t height;
|
||||||
|
size_t depth;
|
||||||
} sizevec_t;
|
} sizevec_t;
|
||||||
|
|
||||||
struct format {
|
struct format
|
||||||
GLenum internal;
|
{
|
||||||
GLenum formattype;
|
GLenum internal;
|
||||||
GLenum datatype;
|
GLenum formattype;
|
||||||
ExplicitType type;
|
GLenum datatype;
|
||||||
|
ExplicitType type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// These are the typically tested formats.
|
// These are the typically tested formats.
|
||||||
@@ -78,6 +80,6 @@ int test_images_get_info_common(cl_device_id device, cl_context context,
|
|||||||
size_t ntargets, sizevec_t *sizes,
|
size_t ntargets, sizevec_t *sizes,
|
||||||
size_t nsizes);
|
size_t nsizes);
|
||||||
|
|
||||||
int is_rgb_101010_supported( cl_context context, GLenum gl_target );
|
int is_rgb_101010_supported(cl_context context, GLenum gl_target);
|
||||||
|
|
||||||
#endif // __COMMON_H__
|
#endif // __COMMON_H__
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#if !defined (__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -31,348 +31,386 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static cl_context sCurrentContext = NULL;
|
static cl_context sCurrentContext = NULL;
|
||||||
|
|
||||||
|
|
||||||
#define TEST_FN_REDIRECT( fn ) ADD_TEST( redirect_##fn )
|
#define TEST_FN_REDIRECT(fn) ADD_TEST(redirect_##fn)
|
||||||
#define TEST_FN_REDIRECTOR( fn ) \
|
#define TEST_FN_REDIRECTOR(fn) \
|
||||||
int test_redirect_##fn(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) \
|
int test_redirect_##fn(cl_device_id device, cl_context context, \
|
||||||
{ \
|
cl_command_queue queue, int numElements) \
|
||||||
int error; \
|
{ \
|
||||||
clCommandQueueWrapper realQueue = clCreateCommandQueueWithProperties( sCurrentContext, device, 0, &error ); \
|
int error; \
|
||||||
test_error( error, "Unable to create command queue" ); \
|
clCommandQueueWrapper realQueue = clCreateCommandQueueWithProperties( \
|
||||||
return test_##fn( device, sCurrentContext, realQueue, numElements ); \
|
sCurrentContext, device, 0, &error); \
|
||||||
}
|
test_error(error, "Unable to create command queue"); \
|
||||||
|
return test_##fn(device, sCurrentContext, realQueue, numElements); \
|
||||||
|
}
|
||||||
|
|
||||||
// buffers:
|
// buffers:
|
||||||
TEST_FN_REDIRECTOR( buffers )
|
TEST_FN_REDIRECTOR(buffers)
|
||||||
TEST_FN_REDIRECTOR( buffers_getinfo )
|
TEST_FN_REDIRECTOR(buffers_getinfo)
|
||||||
|
|
||||||
// 1D images:
|
// 1D images:
|
||||||
TEST_FN_REDIRECTOR( images_read_1D )
|
TEST_FN_REDIRECTOR(images_read_1D)
|
||||||
TEST_FN_REDIRECTOR( images_write_1D )
|
TEST_FN_REDIRECTOR(images_write_1D)
|
||||||
TEST_FN_REDIRECTOR( images_1D_getinfo )
|
TEST_FN_REDIRECTOR(images_1D_getinfo)
|
||||||
|
|
||||||
// 1D image arrays:
|
// 1D image arrays:
|
||||||
TEST_FN_REDIRECTOR( images_read_1Darray )
|
TEST_FN_REDIRECTOR(images_read_1Darray)
|
||||||
TEST_FN_REDIRECTOR( images_write_1Darray )
|
TEST_FN_REDIRECTOR(images_write_1Darray)
|
||||||
TEST_FN_REDIRECTOR( images_1Darray_getinfo )
|
TEST_FN_REDIRECTOR(images_1Darray_getinfo)
|
||||||
|
|
||||||
// 2D images:
|
// 2D images:
|
||||||
TEST_FN_REDIRECTOR( images_read_2D )
|
TEST_FN_REDIRECTOR(images_read_2D)
|
||||||
TEST_FN_REDIRECTOR( images_read_cube )
|
TEST_FN_REDIRECTOR(images_read_cube)
|
||||||
TEST_FN_REDIRECTOR( images_write )
|
TEST_FN_REDIRECTOR(images_write)
|
||||||
TEST_FN_REDIRECTOR( images_write_cube )
|
TEST_FN_REDIRECTOR(images_write_cube)
|
||||||
TEST_FN_REDIRECTOR( images_2D_getinfo )
|
TEST_FN_REDIRECTOR(images_2D_getinfo)
|
||||||
TEST_FN_REDIRECTOR( images_cube_getinfo )
|
TEST_FN_REDIRECTOR(images_cube_getinfo)
|
||||||
|
|
||||||
// 2D image arrays:
|
// 2D image arrays:
|
||||||
TEST_FN_REDIRECTOR( images_read_2Darray )
|
TEST_FN_REDIRECTOR(images_read_2Darray)
|
||||||
TEST_FN_REDIRECTOR( images_write_2Darray )
|
TEST_FN_REDIRECTOR(images_write_2Darray)
|
||||||
TEST_FN_REDIRECTOR( images_2Darray_getinfo )
|
TEST_FN_REDIRECTOR(images_2Darray_getinfo)
|
||||||
|
|
||||||
// 3D images:
|
// 3D images:
|
||||||
TEST_FN_REDIRECTOR( images_read_3D )
|
TEST_FN_REDIRECTOR(images_read_3D)
|
||||||
TEST_FN_REDIRECTOR( images_write_3D )
|
TEST_FN_REDIRECTOR(images_write_3D)
|
||||||
TEST_FN_REDIRECTOR( images_3D_getinfo )
|
TEST_FN_REDIRECTOR(images_3D_getinfo)
|
||||||
|
|
||||||
#ifdef GL_VERSION_3_2
|
#ifdef GL_VERSION_3_2
|
||||||
|
|
||||||
TEST_FN_REDIRECTOR( images_read_texturebuffer )
|
TEST_FN_REDIRECTOR(images_read_texturebuffer)
|
||||||
TEST_FN_REDIRECTOR( images_write_texturebuffer )
|
TEST_FN_REDIRECTOR(images_write_texturebuffer)
|
||||||
TEST_FN_REDIRECTOR( images_texturebuffer_getinfo )
|
TEST_FN_REDIRECTOR(images_texturebuffer_getinfo)
|
||||||
|
|
||||||
// depth textures
|
// depth textures
|
||||||
TEST_FN_REDIRECTOR( images_read_2D_depth )
|
TEST_FN_REDIRECTOR(images_read_2D_depth)
|
||||||
TEST_FN_REDIRECTOR( images_write_2D_depth )
|
TEST_FN_REDIRECTOR(images_write_2D_depth)
|
||||||
TEST_FN_REDIRECTOR( images_read_2Darray_depth )
|
TEST_FN_REDIRECTOR(images_read_2Darray_depth)
|
||||||
TEST_FN_REDIRECTOR( images_write_2Darray_depth )
|
TEST_FN_REDIRECTOR(images_write_2Darray_depth)
|
||||||
|
|
||||||
TEST_FN_REDIRECTOR( images_read_2D_multisample )
|
TEST_FN_REDIRECTOR(images_read_2D_multisample)
|
||||||
TEST_FN_REDIRECTOR( images_read_2Darray_multisample )
|
TEST_FN_REDIRECTOR(images_read_2Darray_multisample)
|
||||||
TEST_FN_REDIRECTOR( image_methods_depth )
|
TEST_FN_REDIRECTOR(image_methods_depth)
|
||||||
TEST_FN_REDIRECTOR( image_methods_multisample )
|
TEST_FN_REDIRECTOR(image_methods_multisample)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Renderbuffer-backed images:
|
// Renderbuffer-backed images:
|
||||||
TEST_FN_REDIRECTOR( renderbuffer_read )
|
TEST_FN_REDIRECTOR(renderbuffer_read)
|
||||||
TEST_FN_REDIRECTOR( renderbuffer_write )
|
TEST_FN_REDIRECTOR(renderbuffer_write)
|
||||||
TEST_FN_REDIRECTOR( renderbuffer_getinfo )
|
TEST_FN_REDIRECTOR(renderbuffer_getinfo)
|
||||||
|
|
||||||
TEST_FN_REDIRECTOR( fence_sync )
|
TEST_FN_REDIRECTOR(fence_sync)
|
||||||
|
|
||||||
test_definition test_list[] = {
|
test_definition test_list[] = { TEST_FN_REDIRECT(buffers),
|
||||||
TEST_FN_REDIRECT( buffers ),
|
TEST_FN_REDIRECT(buffers_getinfo),
|
||||||
TEST_FN_REDIRECT( buffers_getinfo ),
|
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_1D ),
|
TEST_FN_REDIRECT(images_read_1D),
|
||||||
TEST_FN_REDIRECT( images_write_1D ),
|
TEST_FN_REDIRECT(images_write_1D),
|
||||||
TEST_FN_REDIRECT( images_1D_getinfo ),
|
TEST_FN_REDIRECT(images_1D_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_1Darray ),
|
TEST_FN_REDIRECT(images_read_1Darray),
|
||||||
TEST_FN_REDIRECT( images_write_1Darray ),
|
TEST_FN_REDIRECT(images_write_1Darray),
|
||||||
TEST_FN_REDIRECT( images_1Darray_getinfo ),
|
TEST_FN_REDIRECT(images_1Darray_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_2D ),
|
TEST_FN_REDIRECT(images_read_2D),
|
||||||
TEST_FN_REDIRECT( images_write ),
|
TEST_FN_REDIRECT(images_write),
|
||||||
TEST_FN_REDIRECT( images_2D_getinfo ),
|
TEST_FN_REDIRECT(images_2D_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_cube ),
|
TEST_FN_REDIRECT(images_read_cube),
|
||||||
TEST_FN_REDIRECT( images_write_cube ),
|
TEST_FN_REDIRECT(images_write_cube),
|
||||||
TEST_FN_REDIRECT( images_cube_getinfo ),
|
TEST_FN_REDIRECT(images_cube_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_2Darray ),
|
TEST_FN_REDIRECT(images_read_2Darray),
|
||||||
TEST_FN_REDIRECT( images_write_2Darray),
|
TEST_FN_REDIRECT(images_write_2Darray),
|
||||||
TEST_FN_REDIRECT( images_2Darray_getinfo ),
|
TEST_FN_REDIRECT(images_2Darray_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( images_read_3D ),
|
TEST_FN_REDIRECT(images_read_3D),
|
||||||
TEST_FN_REDIRECT( images_write_3D ),
|
TEST_FN_REDIRECT(images_write_3D),
|
||||||
TEST_FN_REDIRECT( images_3D_getinfo ),
|
TEST_FN_REDIRECT(images_3D_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( renderbuffer_read ),
|
TEST_FN_REDIRECT(renderbuffer_read),
|
||||||
TEST_FN_REDIRECT( renderbuffer_write ),
|
TEST_FN_REDIRECT(renderbuffer_write),
|
||||||
TEST_FN_REDIRECT( renderbuffer_getinfo )
|
TEST_FN_REDIRECT(renderbuffer_getinfo) };
|
||||||
};
|
|
||||||
|
|
||||||
test_definition test_list32[] = {
|
test_definition test_list32[] = {
|
||||||
TEST_FN_REDIRECT( images_read_texturebuffer ),
|
TEST_FN_REDIRECT(images_read_texturebuffer),
|
||||||
TEST_FN_REDIRECT( images_write_texturebuffer ),
|
TEST_FN_REDIRECT(images_write_texturebuffer),
|
||||||
TEST_FN_REDIRECT( images_texturebuffer_getinfo ),
|
TEST_FN_REDIRECT(images_texturebuffer_getinfo),
|
||||||
|
|
||||||
TEST_FN_REDIRECT( fence_sync ),
|
TEST_FN_REDIRECT(fence_sync),
|
||||||
TEST_FN_REDIRECT( images_read_2D_depth ),
|
TEST_FN_REDIRECT(images_read_2D_depth),
|
||||||
TEST_FN_REDIRECT( images_write_2D_depth ),
|
TEST_FN_REDIRECT(images_write_2D_depth),
|
||||||
TEST_FN_REDIRECT( images_read_2Darray_depth ),
|
TEST_FN_REDIRECT(images_read_2Darray_depth),
|
||||||
TEST_FN_REDIRECT( images_write_2Darray_depth ),
|
TEST_FN_REDIRECT(images_write_2Darray_depth),
|
||||||
TEST_FN_REDIRECT( images_read_2D_multisample ),
|
TEST_FN_REDIRECT(images_read_2D_multisample),
|
||||||
TEST_FN_REDIRECT( images_read_2Darray_multisample ),
|
TEST_FN_REDIRECT(images_read_2Darray_multisample),
|
||||||
TEST_FN_REDIRECT( image_methods_depth ),
|
TEST_FN_REDIRECT(image_methods_depth),
|
||||||
TEST_FN_REDIRECT( image_methods_multisample )
|
TEST_FN_REDIRECT(image_methods_multisample)
|
||||||
};
|
};
|
||||||
|
|
||||||
const int test_num = ARRAY_SIZE( test_list );
|
const int test_num = ARRAY_SIZE(test_list);
|
||||||
const int test_num32 = ARRAY_SIZE( test_list32 );
|
const int test_num32 = ARRAY_SIZE(test_list32);
|
||||||
|
|
||||||
int main(int argc, const char *argv[])
|
int main(int argc, const char *argv[])
|
||||||
{
|
{
|
||||||
gTestRounding = true;
|
gTestRounding = true;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int numErrors = 0;
|
int numErrors = 0;
|
||||||
|
|
||||||
test_start();
|
test_start();
|
||||||
argc = parseCustomParam(argc, argv);
|
argc = parseCustomParam(argc, argv);
|
||||||
if (argc == -1)
|
if (argc == -1)
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
cl_device_type requestedDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
|
||||||
|
|
||||||
/* Do we have a CPU/GPU specification? */
|
|
||||||
if( argc > 1 )
|
|
||||||
{
|
|
||||||
if( strcmp( argv[ argc - 1 ], "gpu" ) == 0 || strcmp( argv[ argc - 1 ], "CL_DEVICE_TYPE_GPU" ) == 0 )
|
|
||||||
{
|
{
|
||||||
requestedDeviceType = CL_DEVICE_TYPE_GPU;
|
return -1;
|
||||||
argc--;
|
|
||||||
}
|
|
||||||
else if( strcmp( argv[ argc - 1 ], "cpu" ) == 0 || strcmp( argv[ argc - 1 ], "CL_DEVICE_TYPE_CPU" ) == 0 )
|
|
||||||
{
|
|
||||||
requestedDeviceType = CL_DEVICE_TYPE_CPU;
|
|
||||||
argc--;
|
|
||||||
}
|
}
|
||||||
else if( strcmp( argv[ argc - 1 ], "accelerator" ) == 0 || strcmp( argv[ argc - 1 ], "CL_DEVICE_TYPE_ACCELERATOR" ) == 0 )
|
|
||||||
|
cl_device_type requestedDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||||
|
|
||||||
|
/* Do we have a CPU/GPU specification? */
|
||||||
|
if (argc > 1)
|
||||||
{
|
{
|
||||||
requestedDeviceType = CL_DEVICE_TYPE_ACCELERATOR;
|
if (strcmp(argv[argc - 1], "gpu") == 0
|
||||||
argc--;
|
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_GPU") == 0)
|
||||||
|
{
|
||||||
|
requestedDeviceType = CL_DEVICE_TYPE_GPU;
|
||||||
|
argc--;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[argc - 1], "cpu") == 0
|
||||||
|
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_CPU") == 0)
|
||||||
|
{
|
||||||
|
requestedDeviceType = CL_DEVICE_TYPE_CPU;
|
||||||
|
argc--;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[argc - 1], "accelerator") == 0
|
||||||
|
|| strcmp(argv[argc - 1], "CL_DEVICE_TYPE_ACCELERATOR") == 0)
|
||||||
|
{
|
||||||
|
requestedDeviceType = CL_DEVICE_TYPE_ACCELERATOR;
|
||||||
|
argc--;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[argc - 1], "CL_DEVICE_TYPE_DEFAULT") == 0)
|
||||||
|
{
|
||||||
|
requestedDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||||
|
argc--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if( strcmp( argv[ argc - 1 ], "CL_DEVICE_TYPE_DEFAULT" ) == 0 )
|
|
||||||
|
if (argc > 1 && strcmp(argv[1], "-list") == 0)
|
||||||
{
|
{
|
||||||
requestedDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
log_info("Available 2.x tests:\n");
|
||||||
argc--;
|
for (int i = 0; i < test_num; i++)
|
||||||
}
|
log_info("\t%s\n", test_list[i].name);
|
||||||
}
|
|
||||||
|
|
||||||
if( argc > 1 && strcmp( argv[ 1 ], "-list" ) == 0 )
|
log_info("Available 3.2 tests:\n");
|
||||||
{
|
for (int i = 0; i < test_num32; i++)
|
||||||
log_info( "Available 2.x tests:\n" );
|
log_info("\t%s\n", test_list32[i].name);
|
||||||
for( int i = 0; i < test_num; i++ )
|
|
||||||
log_info( "\t%s\n", test_list[i].name );
|
|
||||||
|
|
||||||
log_info( "Available 3.2 tests:\n" );
|
log_info("Note: Any 3.2 test names must follow 2.1 test names on the "
|
||||||
for( int i = 0; i < test_num32; i++ )
|
"command line.\n");
|
||||||
log_info( "\t%s\n", test_list32[i].name );
|
log_info("Use environment variables to specify desired device.\n");
|
||||||
|
|
||||||
log_info( "Note: Any 3.2 test names must follow 2.1 test names on the command line.\n" );
|
|
||||||
log_info( "Use environment variables to specify desired device.\n" );
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if any 2.x or 3.2 test names were specified on the command line.
|
// Check to see if any 2.x or 3.2 test names were specified on the command
|
||||||
unsigned first_32_testname = 0;
|
// line.
|
||||||
|
unsigned first_32_testname = 0;
|
||||||
|
|
||||||
for (int j=1; (j<argc) && (!first_32_testname); ++j)
|
for (int j = 1; (j < argc) && (!first_32_testname); ++j)
|
||||||
for (int i = 0; i < test_num32; ++i)
|
for (int i = 0; i < test_num32; ++i)
|
||||||
if (strcmp(test_list32[i].name, argv[j]) == 0) {
|
if (strcmp(test_list32[i].name, argv[j]) == 0)
|
||||||
first_32_testname = j;
|
{
|
||||||
break;
|
first_32_testname = j;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// Create the environment for the test.
|
// Create the environment for the test.
|
||||||
GLEnvironment *glEnv = GLEnvironment::Instance();
|
GLEnvironment *glEnv = GLEnvironment::Instance();
|
||||||
|
|
||||||
// Check if any devices of the requested type support CL/GL interop.
|
// Check if any devices of the requested type support CL/GL interop.
|
||||||
int supported = glEnv->SupportsCLGLInterop( requestedDeviceType );
|
int supported = glEnv->SupportsCLGLInterop(requestedDeviceType);
|
||||||
if( supported == 0 ) {
|
if (supported == 0)
|
||||||
log_info("Test not run because GL-CL interop is not supported for any devices of the requested type.\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because GL-CL interop is not supported for any "
|
||||||
} else if ( supported == -1 ) {
|
"devices of the requested type.\n");
|
||||||
log_error("Unable to setup the test or failed to determine if CL-GL interop is supported.\n");
|
return 0;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize function pointers.
|
|
||||||
error = init_clgl_ext();
|
|
||||||
if (error < 0) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenGL tests for non-3.2 ////////////////////////////////////////////////////////
|
|
||||||
if ((argc == 1) || (first_32_testname != 1)) {
|
|
||||||
|
|
||||||
// At least one device supports CL-GL interop, so init the test.
|
|
||||||
if( glEnv->Init( &argc, (char **)argv, CL_FALSE ) ) {
|
|
||||||
log_error("Failed to initialize the GL environment for this test.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
else if (supported == -1)
|
||||||
// Create a context to use and then grab a device (or devices) from it
|
{
|
||||||
sCurrentContext = glEnv->CreateCLContext();
|
log_error("Unable to setup the test or failed to determine if CL-GL "
|
||||||
if( sCurrentContext == NULL )
|
"interop is supported.\n");
|
||||||
{
|
|
||||||
log_error( "ERROR: Unable to obtain CL context from GL\n" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t numDevices = 0;
|
|
||||||
cl_device_id *deviceIDs;
|
|
||||||
|
|
||||||
error = clGetContextInfo( sCurrentContext, CL_CONTEXT_DEVICES, 0, NULL, &numDevices);
|
|
||||||
if( error != CL_SUCCESS )
|
|
||||||
{
|
|
||||||
print_error( error, "Unable to get device count from context" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
|
||||||
if (deviceIDs == NULL) {
|
|
||||||
print_error( error, "malloc failed" );
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
error = clGetContextInfo( sCurrentContext, CL_CONTEXT_DEVICES, numDevices, deviceIDs, NULL);
|
|
||||||
if( error != CL_SUCCESS ) {
|
// Initialize function pointers.
|
||||||
print_error( error, "Unable to get device list from context" );
|
error = init_clgl_ext();
|
||||||
return -1;
|
if (error < 0)
|
||||||
|
{
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
numDevices /= sizeof(cl_device_id);
|
// OpenGL tests for non-3.2
|
||||||
|
// ////////////////////////////////////////////////////////
|
||||||
|
if ((argc == 1) || (first_32_testname != 1))
|
||||||
|
{
|
||||||
|
|
||||||
if (numDevices < 1) {
|
// At least one device supports CL-GL interop, so init the test.
|
||||||
log_error("No devices found.\n");
|
if (glEnv->Init(&argc, (char **)argv, CL_FALSE))
|
||||||
return -1;
|
{
|
||||||
}
|
log_error(
|
||||||
|
"Failed to initialize the GL environment for this test.\n");
|
||||||
// Execute tests.
|
return -1;
|
||||||
int argc_ = (first_32_testname) ? first_32_testname : argc;
|
|
||||||
|
|
||||||
for( size_t i = 0; i < numDevices; i++ ) {
|
|
||||||
log_info( "\nTesting OpenGL 2.x\n" );
|
|
||||||
if( printDeviceHeader( deviceIDs[ i ] ) != CL_SUCCESS ) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: don't use the entire harness, because we have a different way of obtaining the device (via the context)
|
// Create a context to use and then grab a device (or devices) from it
|
||||||
error = parseAndCallCommandLineTests( argc_, argv, deviceIDs[i], test_num, test_list, true, 0, 1024 );
|
sCurrentContext = glEnv->CreateCLContext();
|
||||||
if( error != 0 )
|
if (sCurrentContext == NULL)
|
||||||
break;
|
{
|
||||||
}
|
log_error("ERROR: Unable to obtain CL context from GL\n");
|
||||||
|
return -1;
|
||||||
numErrors += error;
|
|
||||||
|
|
||||||
// Clean-up.
|
|
||||||
free(deviceIDs);
|
|
||||||
clReleaseContext( sCurrentContext );
|
|
||||||
//delete glEnv;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OpenGL 3.2 tests. ////////////////////////////////////////////////////////
|
|
||||||
if ((argc==1) || first_32_testname) {
|
|
||||||
|
|
||||||
// At least one device supports CL-GL interop, so init the test.
|
|
||||||
if( glEnv->Init( &argc, (char **)argv, CL_TRUE ) ) {
|
|
||||||
log_error("Failed to initialize the GL environment for this test.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a context to use and then grab a device (or devices) from it
|
|
||||||
sCurrentContext = glEnv->CreateCLContext();
|
|
||||||
if( sCurrentContext == NULL ) {
|
|
||||||
log_error( "ERROR: Unable to obtain CL context from GL\n" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t numDevices = 0;
|
|
||||||
cl_device_id *deviceIDs;
|
|
||||||
|
|
||||||
error = clGetContextInfo( sCurrentContext, CL_CONTEXT_DEVICES, 0, NULL, &numDevices);
|
|
||||||
if( error != CL_SUCCESS ) {
|
|
||||||
print_error( error, "Unable to get device count from context" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
|
||||||
if (deviceIDs == NULL) {
|
|
||||||
print_error( error, "malloc failed" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
error = clGetContextInfo( sCurrentContext, CL_CONTEXT_DEVICES, numDevices, deviceIDs, NULL);
|
|
||||||
if( error != CL_SUCCESS ) {
|
|
||||||
print_error( error, "Unable to get device list from context" );
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
numDevices /= sizeof(cl_device_id);
|
|
||||||
|
|
||||||
if (numDevices < 1) {
|
|
||||||
log_error("No devices found.\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int argc_ = (first_32_testname) ? 1 + (argc - first_32_testname) : argc;
|
|
||||||
const char** argv_ = (first_32_testname) ? &argv[first_32_testname-1] : argv;
|
|
||||||
|
|
||||||
// Execute the tests.
|
|
||||||
for( size_t i = 0; i < numDevices; i++ ) {
|
|
||||||
log_info( "\nTesting OpenGL 3.2\n" );
|
|
||||||
if( printDeviceHeader( deviceIDs[ i ] ) != CL_SUCCESS ) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: don't use the entire harness, because we have a different way of obtaining the device (via the context)
|
size_t numDevices = 0;
|
||||||
error = parseAndCallCommandLineTests( argc_, argv_, deviceIDs[i], test_num32, test_list32, true, 0, 1024 );
|
cl_device_id *deviceIDs;
|
||||||
if( error != 0 )
|
|
||||||
break;
|
error = clGetContextInfo(sCurrentContext, CL_CONTEXT_DEVICES, 0, NULL,
|
||||||
|
&numDevices);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
print_error(error, "Unable to get device count from context");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||||
|
if (deviceIDs == NULL)
|
||||||
|
{
|
||||||
|
print_error(error, "malloc failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
error = clGetContextInfo(sCurrentContext, CL_CONTEXT_DEVICES,
|
||||||
|
numDevices, deviceIDs, NULL);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
print_error(error, "Unable to get device list from context");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
numDevices /= sizeof(cl_device_id);
|
||||||
|
|
||||||
|
if (numDevices < 1)
|
||||||
|
{
|
||||||
|
log_error("No devices found.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Execute tests.
|
||||||
|
int argc_ = (first_32_testname) ? first_32_testname : argc;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < numDevices; i++)
|
||||||
|
{
|
||||||
|
log_info("\nTesting OpenGL 2.x\n");
|
||||||
|
if (printDeviceHeader(deviceIDs[i]) != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: don't use the entire harness, because we have a different
|
||||||
|
// way of obtaining the device (via the context)
|
||||||
|
error = parseAndCallCommandLineTests(
|
||||||
|
argc_, argv, deviceIDs[i], test_num, test_list, true, 0, 1024);
|
||||||
|
if (error != 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
numErrors += error;
|
||||||
|
|
||||||
|
// Clean-up.
|
||||||
|
free(deviceIDs);
|
||||||
|
clReleaseContext(sCurrentContext);
|
||||||
|
// delete glEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
numErrors += error;
|
// OpenGL 3.2 tests.
|
||||||
|
// ////////////////////////////////////////////////////////
|
||||||
|
if ((argc == 1) || first_32_testname)
|
||||||
|
{
|
||||||
|
|
||||||
// Clean-up.
|
// At least one device supports CL-GL interop, so init the test.
|
||||||
free(deviceIDs);
|
if (glEnv->Init(&argc, (char **)argv, CL_TRUE))
|
||||||
clReleaseContext( sCurrentContext );
|
{
|
||||||
delete glEnv;
|
log_error(
|
||||||
|
"Failed to initialize the GL environment for this test.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// Create a context to use and then grab a device (or devices) from it
|
||||||
|
sCurrentContext = glEnv->CreateCLContext();
|
||||||
|
if (sCurrentContext == NULL)
|
||||||
|
{
|
||||||
|
log_error("ERROR: Unable to obtain CL context from GL\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
//All done.
|
size_t numDevices = 0;
|
||||||
return numErrors;
|
cl_device_id *deviceIDs;
|
||||||
|
|
||||||
|
error = clGetContextInfo(sCurrentContext, CL_CONTEXT_DEVICES, 0, NULL,
|
||||||
|
&numDevices);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
print_error(error, "Unable to get device count from context");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||||
|
if (deviceIDs == NULL)
|
||||||
|
{
|
||||||
|
print_error(error, "malloc failed");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
error = clGetContextInfo(sCurrentContext, CL_CONTEXT_DEVICES,
|
||||||
|
numDevices, deviceIDs, NULL);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
print_error(error, "Unable to get device list from context");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
numDevices /= sizeof(cl_device_id);
|
||||||
|
|
||||||
|
if (numDevices < 1)
|
||||||
|
{
|
||||||
|
log_error("No devices found.\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int argc_ = (first_32_testname) ? 1 + (argc - first_32_testname) : argc;
|
||||||
|
const char **argv_ =
|
||||||
|
(first_32_testname) ? &argv[first_32_testname - 1] : argv;
|
||||||
|
|
||||||
|
// Execute the tests.
|
||||||
|
for (size_t i = 0; i < numDevices; i++)
|
||||||
|
{
|
||||||
|
log_info("\nTesting OpenGL 3.2\n");
|
||||||
|
if (printDeviceHeader(deviceIDs[i]) != CL_SUCCESS)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note: don't use the entire harness, because we have a different
|
||||||
|
// way of obtaining the device (via the context)
|
||||||
|
error = parseAndCallCommandLineTests(argc_, argv_, deviceIDs[i],
|
||||||
|
test_num32, test_list32, true,
|
||||||
|
0, 1024);
|
||||||
|
if (error != 0) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
numErrors += error;
|
||||||
|
|
||||||
|
// Clean-up.
|
||||||
|
free(deviceIDs);
|
||||||
|
clReleaseContext(sCurrentContext);
|
||||||
|
delete glEnv;
|
||||||
|
}
|
||||||
|
|
||||||
|
// All done.
|
||||||
|
return numErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -20,121 +20,134 @@
|
|||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma Misc tests
|
#pragma Misc tests
|
||||||
|
|
||||||
extern int test_buffers( cl_device_id device, cl_context context,
|
extern int test_buffers(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_fence_sync( cl_device_id device, cl_context context,
|
extern int test_fence_sync(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Tead tests
|
#pragma mark Tead tests
|
||||||
|
|
||||||
extern int test_images_read_2D( cl_device_id device, cl_context context,
|
extern int test_images_read_2D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_1D( cl_device_id device, cl_context context,
|
extern int test_images_read_1D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_texturebuffer( cl_device_id device, cl_context context,
|
extern int test_images_read_texturebuffer(cl_device_id device,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_1Darray( cl_device_id device, cl_context context,
|
extern int test_images_read_1Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_2Darray( cl_device_id device, cl_context context,
|
extern int test_images_read_2Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_cube( cl_device_id device, cl_context context,
|
extern int test_images_read_cube(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_read_3D( cl_device_id device, cl_context context,
|
extern int test_images_read_3D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_renderbuffer_read( cl_device_id device, cl_context context,
|
extern int test_renderbuffer_read(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Write tests
|
#pragma mark Write tests
|
||||||
|
|
||||||
// 2D tests are the ones with no suffix:
|
// 2D tests are the ones with no suffix:
|
||||||
|
|
||||||
extern int test_images_write( cl_device_id device, cl_context context,
|
extern int test_images_write(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_write_cube( cl_device_id device, cl_context context,
|
extern int test_images_write_cube(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_renderbuffer_write( cl_device_id device, cl_context context,
|
extern int test_renderbuffer_write(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
// Here are the rest:
|
// Here are the rest:
|
||||||
|
|
||||||
extern int test_images_write_1D( cl_device_id device, cl_context context,
|
extern int test_images_write_1D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_write_texturebuffer( cl_device_id device, cl_context context,
|
extern int test_images_write_texturebuffer(cl_device_id device,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int num_elements);
|
||||||
|
|
||||||
extern int test_images_write_1Darray( cl_device_id device, cl_context context,
|
extern int test_images_write_1Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_write_2Darray( cl_device_id device, cl_context context,
|
extern int test_images_write_2Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
extern int test_images_write_3D( cl_device_id device, cl_context context,
|
extern int test_images_write_3D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int num_elements );
|
cl_command_queue queue, int num_elements);
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark Get info test entry points
|
#pragma mark Get info test entry points
|
||||||
|
|
||||||
extern int test_buffers_getinfo( cl_device_id device, cl_context context,
|
extern int test_buffers_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_1D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_texturebuffer_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_texturebuffer_getinfo(cl_device_id device,
|
||||||
cl_command_queue queue, int numElements );
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int numElements);
|
||||||
|
|
||||||
extern int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_1Darray_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_2D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_2Darray_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_cube_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
extern int test_images_3D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_read_2D_depth( cl_device_id device, cl_context context,
|
extern int test_images_read_2D_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_write_2D_depth( cl_device_id device, cl_context context,
|
extern int test_images_write_2D_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
|
|
||||||
extern int test_images_read_2Darray_depth( cl_device_id device, cl_context context,
|
extern int test_images_read_2Darray_depth(cl_device_id device,
|
||||||
cl_command_queue queue, int );
|
cl_context context,
|
||||||
|
cl_command_queue queue, int);
|
||||||
|
|
||||||
extern int test_images_write_2Darray_depth( cl_device_id device, cl_context context,
|
extern int test_images_write_2Darray_depth(cl_device_id device,
|
||||||
cl_command_queue queue, int numElements );
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int numElements);
|
||||||
|
|
||||||
extern int test_images_read_2D_multisample( cl_device_id device, cl_context context,
|
extern int test_images_read_2D_multisample(cl_device_id device,
|
||||||
cl_command_queue queue, int numElements );
|
cl_context context,
|
||||||
|
cl_command_queue queue,
|
||||||
|
int numElements);
|
||||||
|
|
||||||
extern int test_images_read_2Darray_multisample( cl_device_id device, cl_context context,
|
extern int test_images_read_2Darray_multisample(cl_device_id device,
|
||||||
cl_command_queue queue, int );
|
cl_context context,
|
||||||
|
cl_command_queue queue, int);
|
||||||
|
|
||||||
extern int test_image_methods_depth( cl_device_id device, cl_context context,
|
extern int test_image_methods_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int );
|
cl_command_queue queue, int);
|
||||||
|
|
||||||
extern int test_image_methods_multisample( cl_device_id device, cl_context context,
|
extern int test_image_methods_multisample(cl_device_id device,
|
||||||
cl_command_queue queue, int );
|
cl_context context,
|
||||||
|
cl_command_queue queue, int);
|
||||||
|
|
||||||
extern int test_renderbuffer_getinfo( cl_device_id device, cl_context context,
|
extern int test_renderbuffer_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements );
|
cl_command_queue queue, int numElements);
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if !defined (__APPLE__)
|
#if !defined(__APPLE__)
|
||||||
#include <CL/cl.h>
|
#include <CL/cl.h>
|
||||||
#include "gl/gl_headers.h"
|
#include "gl/gl_headers.h"
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
@@ -40,25 +40,40 @@
|
|||||||
|
|
||||||
#include "gl/helpers.h"
|
#include "gl/helpers.h"
|
||||||
|
|
||||||
extern const char *get_kernel_suffix( cl_image_format *format );
|
extern const char *get_kernel_suffix(cl_image_format *format);
|
||||||
extern const char *get_write_conversion( cl_image_format *format, ExplicitType type);
|
extern const char *get_write_conversion(cl_image_format *format,
|
||||||
extern ExplicitType get_read_kernel_type( cl_image_format *format );
|
ExplicitType type);
|
||||||
extern ExplicitType get_write_kernel_type( cl_image_format *format );
|
extern ExplicitType get_read_kernel_type(cl_image_format *format);
|
||||||
|
extern ExplicitType get_write_kernel_type(cl_image_format *format);
|
||||||
|
|
||||||
extern char * convert_to_expected( void * inputBuffer, size_t numPixels, ExplicitType inType, ExplicitType outType, size_t channelNum, GLenum glDataType = 0);
|
extern char *convert_to_expected(void *inputBuffer, size_t numPixels,
|
||||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum, size_t typeSize );
|
ExplicitType inType, ExplicitType outType,
|
||||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum, size_t typeSize );
|
size_t channelNum, GLenum glDataType = 0);
|
||||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum, size_t channelNum );
|
extern int validate_integer_results(void *expectedResults, void *actualResults,
|
||||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum, size_t channelNum );
|
size_t width, size_t height,
|
||||||
extern int validate_float_results_rgb_101010( void *expectedResults, void *actualResults, size_t width, size_t height, size_t sampleNum );
|
size_t sampleNum, size_t typeSize);
|
||||||
extern int validate_float_results_rgb_101010( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t sampleNum );
|
extern int validate_integer_results(void *expectedResults, void *actualResults,
|
||||||
|
size_t width, size_t height, size_t depth,
|
||||||
|
size_t sampleNum, size_t typeSize);
|
||||||
|
extern int validate_float_results(void *expectedResults, void *actualResults,
|
||||||
|
size_t width, size_t height, size_t sampleNum,
|
||||||
|
size_t channelNum);
|
||||||
|
extern int validate_float_results(void *expectedResults, void *actualResults,
|
||||||
|
size_t width, size_t height, size_t depth,
|
||||||
|
size_t sampleNum, size_t channelNum);
|
||||||
|
extern int validate_float_results_rgb_101010(void *expectedResults,
|
||||||
|
void *actualResults, size_t width,
|
||||||
|
size_t height, size_t sampleNum);
|
||||||
|
extern int validate_float_results_rgb_101010(void *expectedResults,
|
||||||
|
void *actualResults, size_t width,
|
||||||
|
size_t height, size_t depth,
|
||||||
|
size_t sampleNum);
|
||||||
|
|
||||||
extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type, GLuint expected_gl_name,
|
extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type,
|
||||||
GLenum expected_cl_gl_texture_target, GLint expected_cl_gl_mipmap_level);
|
GLuint expected_gl_name,
|
||||||
|
GLenum expected_cl_gl_texture_target,
|
||||||
|
GLint expected_cl_gl_mipmap_level);
|
||||||
|
|
||||||
extern bool CheckGLIntegerExtensionSupport();
|
extern bool CheckGLIntegerExtensionSupport();
|
||||||
|
|
||||||
#endif // _testBase_h
|
#endif // _testBase_h
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -113,6 +113,7 @@ typedef cl_event(CL_API_CALL *clCreateEventFromGLsyncKHR_fn)(
|
|||||||
clCreateEventFromGLsyncKHR_fn clCreateEventFromGLsyncKHR_ptr;
|
clCreateEventFromGLsyncKHR_fn clCreateEventFromGLsyncKHR_ptr;
|
||||||
|
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
static const char *updateBuffersKernel[] = {
|
static const char *updateBuffersKernel[] = {
|
||||||
"__kernel void update( __global float4 * vertices, __global float4 "
|
"__kernel void update( __global float4 * vertices, __global float4 "
|
||||||
"*colors, int horizWrap, int rowIdx )\n"
|
"*colors, int horizWrap, int rowIdx )\n"
|
||||||
@@ -132,6 +133,7 @@ static const char *updateBuffersKernel[] = {
|
|||||||
" colors[ tid * 2 + 1 ] = colors[ tid * 2 + 0 ];\n"
|
" colors[ tid * 2 + 1 ] = colors[ tid * 2 + 0 ];\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
};
|
};
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
// Passthrough VertexShader
|
// Passthrough VertexShader
|
||||||
static const char *vertexshader = "#version 150\n"
|
static const char *vertexshader = "#version 150\n"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -24,16 +24,17 @@ struct image_kernel_data
|
|||||||
cl_int width;
|
cl_int width;
|
||||||
cl_int height;
|
cl_int height;
|
||||||
cl_int depth;
|
cl_int depth;
|
||||||
cl_int arraySize;
|
cl_int arraySize;
|
||||||
cl_int widthDim;
|
cl_int widthDim;
|
||||||
cl_int heightDim;
|
cl_int heightDim;
|
||||||
cl_int channelType;
|
cl_int channelType;
|
||||||
cl_int channelOrder;
|
cl_int channelOrder;
|
||||||
cl_int expectedChannelType;
|
cl_int expectedChannelType;
|
||||||
cl_int expectedChannelOrder;
|
cl_int expectedChannelOrder;
|
||||||
cl_int numSamples;
|
cl_int numSamples;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// clang-format off
|
||||||
static const char *methodTestKernelPattern =
|
static const char *methodTestKernelPattern =
|
||||||
"%s"
|
"%s"
|
||||||
"typedef struct {\n"
|
"typedef struct {\n"
|
||||||
@@ -53,239 +54,260 @@ static const char *methodTestKernelPattern =
|
|||||||
"{\n"
|
"{\n"
|
||||||
"%s%s%s%s%s%s%s%s%s%s%s"
|
"%s%s%s%s%s%s%s%s%s%s%s"
|
||||||
"}\n";
|
"}\n";
|
||||||
|
// clang-format on
|
||||||
|
|
||||||
static const char *arraySizeKernelLine =
|
static const char *arraySizeKernelLine =
|
||||||
" outData->arraySize = get_image_array_size( input );\n";
|
" outData->arraySize = get_image_array_size( input );\n";
|
||||||
static const char *imageWidthKernelLine =
|
static const char *imageWidthKernelLine =
|
||||||
" outData->width = get_image_width( input );\n";
|
" outData->width = get_image_width( input );\n";
|
||||||
static const char *imageHeightKernelLine =
|
static const char *imageHeightKernelLine =
|
||||||
" outData->height = get_image_height( input );\n";
|
" outData->height = get_image_height( input );\n";
|
||||||
static const char *imageDimKernelLine =
|
static const char *imageDimKernelLine =
|
||||||
" int2 dim = get_image_dim( input );\n";
|
" int2 dim = get_image_dim( input );\n";
|
||||||
static const char *imageWidthDimKernelLine =
|
static const char *imageWidthDimKernelLine = " outData->widthDim = dim.x;\n";
|
||||||
" outData->widthDim = dim.x;\n";
|
|
||||||
static const char *imageHeightDimKernelLine =
|
static const char *imageHeightDimKernelLine =
|
||||||
" outData->heightDim = dim.y;\n";
|
" outData->heightDim = dim.y;\n";
|
||||||
static const char *channelTypeKernelLine =
|
static const char *channelTypeKernelLine =
|
||||||
" outData->channelType = get_image_channel_data_type( input );\n";
|
" outData->channelType = get_image_channel_data_type( input );\n";
|
||||||
static const char *channelTypeConstLine =
|
static const char *channelTypeConstLine =
|
||||||
" outData->expectedChannelType = CLK_%s;\n";
|
" outData->expectedChannelType = CLK_%s;\n";
|
||||||
static const char *channelOrderKernelLine =
|
static const char *channelOrderKernelLine =
|
||||||
" outData->channelOrder = get_image_channel_order( input );\n";
|
" outData->channelOrder = get_image_channel_order( input );\n";
|
||||||
static const char *channelOrderConstLine =
|
static const char *channelOrderConstLine =
|
||||||
" outData->expectedChannelOrder = CLK_%s;\n";
|
" outData->expectedChannelOrder = CLK_%s;\n";
|
||||||
static const char *numSamplesKernelLine =
|
static const char *numSamplesKernelLine =
|
||||||
" outData->numSamples = get_image_num_samples( input );\n";
|
" outData->numSamples = get_image_num_samples( input );\n";
|
||||||
static const char *enableMSAAKernelLine =
|
static const char *enableMSAAKernelLine =
|
||||||
"#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable\n";
|
"#pragma OPENCL EXTENSION cl_khr_gl_msaa_sharing : enable\n";
|
||||||
|
|
||||||
static int verify(cl_int input, cl_int kernelOutput, const char * description)
|
static int verify(cl_int input, cl_int kernelOutput, const char *description)
|
||||||
{
|
{
|
||||||
if( kernelOutput != input )
|
if (kernelOutput != input)
|
||||||
{
|
{
|
||||||
log_error( "ERROR: %s did not validate (expected %d, got %d)\n", description, input, kernelOutput);
|
log_error("ERROR: %s did not validate (expected %d, got %d)\n",
|
||||||
return -1;
|
description, input, kernelOutput);
|
||||||
}
|
return -1;
|
||||||
return 0;
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern int supportsMsaa(cl_context context, bool* supports_msaa);
|
extern int supportsMsaa(cl_context context, bool *supports_msaa);
|
||||||
extern int supportsDepth(cl_context context, bool* supports_depth);
|
extern int supportsDepth(cl_context context, bool *supports_depth);
|
||||||
|
|
||||||
int test_image_format_methods( cl_device_id device, cl_context context, cl_command_queue queue,
|
int test_image_format_methods(cl_device_id device, cl_context context,
|
||||||
size_t width, size_t height, size_t arraySize, size_t samples,
|
cl_command_queue queue, size_t width,
|
||||||
GLenum target, format format, MTdata d )
|
size_t height, size_t arraySize, size_t samples,
|
||||||
|
GLenum target, format format, MTdata d)
|
||||||
{
|
{
|
||||||
int error, result=0;
|
int error, result = 0;
|
||||||
|
|
||||||
clProgramWrapper program;
|
clProgramWrapper program;
|
||||||
clKernelWrapper kernel;
|
clKernelWrapper kernel;
|
||||||
clMemWrapper image, outDataBuffer;
|
clMemWrapper image, outDataBuffer;
|
||||||
char programSrc[ 10240 ];
|
char programSrc[10240];
|
||||||
|
|
||||||
image_kernel_data outKernelData;
|
image_kernel_data outKernelData;
|
||||||
|
|
||||||
#ifdef GL_VERSION_3_2
|
#ifdef GL_VERSION_3_2
|
||||||
if (get_base_gl_target(target) == GL_TEXTURE_2D_MULTISAMPLE ||
|
if (get_base_gl_target(target) == GL_TEXTURE_2D_MULTISAMPLE
|
||||||
get_base_gl_target(target) == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
|| get_base_gl_target(target) == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
||||||
{
|
{
|
||||||
bool supports_msaa;
|
bool supports_msaa;
|
||||||
error = supportsMsaa(context, &supports_msaa);
|
error = supportsMsaa(context, &supports_msaa);
|
||||||
if( error != 0 ) return error;
|
if (error != 0) return error;
|
||||||
if (!supports_msaa) return 0;
|
if (!supports_msaa) return 0;
|
||||||
}
|
}
|
||||||
if (format.formattype == GL_DEPTH_COMPONENT ||
|
if (format.formattype == GL_DEPTH_COMPONENT
|
||||||
format.formattype == GL_DEPTH_STENCIL)
|
|| format.formattype == GL_DEPTH_STENCIL)
|
||||||
{
|
{
|
||||||
bool supports_depth;
|
bool supports_depth;
|
||||||
error = supportsDepth(context, &supports_depth);
|
error = supportsDepth(context, &supports_depth);
|
||||||
if( error != 0 ) return error;
|
if (error != 0) return error;
|
||||||
if (!supports_depth) return 0;
|
if (!supports_depth) return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
DetectFloatToHalfRoundingMode(queue);
|
DetectFloatToHalfRoundingMode(queue);
|
||||||
|
|
||||||
glTextureWrapper glTexture;
|
glTextureWrapper glTexture;
|
||||||
switch (get_base_gl_target(target)) {
|
switch (get_base_gl_target(target))
|
||||||
case GL_TEXTURE_2D:
|
{
|
||||||
CreateGLTexture2D( width, height, target,
|
case GL_TEXTURE_2D:
|
||||||
format.formattype, format.internal, format.datatype,
|
CreateGLTexture2D(width, height, target, format.formattype,
|
||||||
format.type, &glTexture, &error, false, d );
|
format.internal, format.datatype, format.type,
|
||||||
break;
|
&glTexture, &error, false, d);
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
break;
|
||||||
CreateGLTexture2DArray( width, height, arraySize, target,
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
format.formattype, format.internal, format.datatype,
|
CreateGLTexture2DArray(width, height, arraySize, target,
|
||||||
format.type, &glTexture, &error, false, d );
|
format.formattype, format.internal,
|
||||||
break;
|
format.datatype, format.type, &glTexture,
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
&error, false, d);
|
||||||
CreateGLTexture2DMultisample( width, height, samples, target,
|
break;
|
||||||
format.formattype, format.internal, format.datatype,
|
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||||
format.type, &glTexture, &error, false, d, false);
|
CreateGLTexture2DMultisample(width, height, samples, target,
|
||||||
break;
|
format.formattype, format.internal,
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
format.datatype, format.type,
|
||||||
CreateGLTexture2DArrayMultisample( width, height, arraySize, samples, target,
|
&glTexture, &error, false, d, false);
|
||||||
format.formattype, format.internal, format.datatype,
|
break;
|
||||||
format.type, &glTexture, &error, false, d, false);
|
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||||
break;
|
CreateGLTexture2DArrayMultisample(
|
||||||
|
width, height, arraySize, samples, target, format.formattype,
|
||||||
|
format.internal, format.datatype, format.type, &glTexture,
|
||||||
|
&error, false, d, false);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log_error("Unsupported GL tex target (%s) passed to write test: "
|
log_error("Unsupported GL tex target (%s) passed to write test: "
|
||||||
"%s (%s):%d", GetGLTargetName(target), __FUNCTION__,
|
"%s (%s):%d",
|
||||||
__FILE__, __LINE__);
|
GetGLTargetName(target), __FUNCTION__, __FILE__,
|
||||||
}
|
__LINE__);
|
||||||
|
}
|
||||||
|
|
||||||
// Check to see if the texture could not be created for some other reason like
|
// Check to see if the texture could not be created for some other reason
|
||||||
// GL_FRAMEBUFFER_UNSUPPORTED
|
// like GL_FRAMEBUFFER_UNSUPPORTED
|
||||||
if (error == GL_FRAMEBUFFER_UNSUPPORTED) {
|
if (error == GL_FRAMEBUFFER_UNSUPPORTED)
|
||||||
return 0;
|
{
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Construct testing source
|
// Construct testing source
|
||||||
log_info( " - Creating image %d by %d...\n", width, height );
|
log_info(" - Creating image %d by %d...\n", width, height);
|
||||||
// Create a CL image from the supplied GL texture
|
// Create a CL image from the supplied GL texture
|
||||||
image = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
image = (*clCreateFromGLTexture_ptr)(context, CL_MEM_READ_ONLY, target, 0,
|
||||||
target, 0, glTexture, &error );
|
glTexture, &error);
|
||||||
|
|
||||||
if ( error != CL_SUCCESS ) {
|
if (error != CL_SUCCESS)
|
||||||
print_error( error, "Unable to create CL image from GL texture" );
|
{
|
||||||
GLint fmt;
|
print_error(error, "Unable to create CL image from GL texture");
|
||||||
glGetTexLevelParameteriv( target, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
GLint fmt;
|
||||||
log_error( " Supplied GL texture was base format %s and internal "
|
glGetTexLevelParameteriv(target, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
|
||||||
"format %s\n", GetGLBaseFormatName( fmt ), GetGLFormatName( fmt ) );
|
log_error(" Supplied GL texture was base format %s and internal "
|
||||||
return error;
|
"format %s\n",
|
||||||
}
|
GetGLBaseFormatName(fmt), GetGLFormatName(fmt));
|
||||||
|
return error;
|
||||||
cl_image_format imageFormat;
|
|
||||||
error = clGetImageInfo (image, CL_IMAGE_FORMAT,
|
|
||||||
sizeof(imageFormat), &imageFormat, NULL);
|
|
||||||
test_error(error, "Failed to get image format");
|
|
||||||
|
|
||||||
const char * imageType = 0;
|
|
||||||
bool doArraySize = false;
|
|
||||||
bool doImageWidth = false;
|
|
||||||
bool doImageHeight = false;
|
|
||||||
bool doImageChannelDataType = false;
|
|
||||||
bool doImageChannelOrder = false;
|
|
||||||
bool doImageDim = false;
|
|
||||||
bool doNumSamples = false;
|
|
||||||
bool doMSAA = false;
|
|
||||||
switch(target) {
|
|
||||||
case GL_TEXTURE_2D:
|
|
||||||
imageType = "image2d_depth_t";
|
|
||||||
doImageWidth = true;
|
|
||||||
doImageHeight = true;
|
|
||||||
doImageChannelDataType = true;
|
|
||||||
doImageChannelOrder = true;
|
|
||||||
doImageDim = true;
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
|
||||||
imageType = "image2d_array_depth_t";
|
|
||||||
doImageWidth = true;
|
|
||||||
doImageHeight = true;
|
|
||||||
doArraySize = true;
|
|
||||||
doImageChannelDataType = true;
|
|
||||||
doImageChannelOrder = true;
|
|
||||||
doImageDim = true;
|
|
||||||
doArraySize = true;
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE:
|
|
||||||
doNumSamples = true;
|
|
||||||
doMSAA = true;
|
|
||||||
if(format.formattype == GL_DEPTH_COMPONENT) {
|
|
||||||
doImageWidth = true;
|
|
||||||
imageType = "image2d_msaa_depth_t";
|
|
||||||
} else {
|
|
||||||
imageType = "image2d_msaa_t";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
|
||||||
doMSAA = true;
|
|
||||||
if(format.formattype == GL_DEPTH_COMPONENT) {
|
|
||||||
doImageWidth = true;
|
|
||||||
imageType = "image2d_msaa_array_depth_t";
|
|
||||||
} else {
|
|
||||||
imageType = "image2d_array_msaa_t";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char channelTypeConstKernelLine[512] = {0};
|
|
||||||
char channelOrderConstKernelLine[512] = {0};
|
|
||||||
const char* channelTypeName=0;
|
|
||||||
const char* channelOrderName=0;
|
|
||||||
if(doImageChannelDataType) {
|
|
||||||
channelTypeName = GetChannelTypeName( imageFormat.image_channel_data_type );
|
|
||||||
if(channelTypeName && strlen(channelTypeName)) {
|
|
||||||
// replace CL_* with CLK_*
|
|
||||||
sprintf(channelTypeConstKernelLine, channelTypeConstLine, &channelTypeName[3]);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(doImageChannelOrder) {
|
cl_image_format imageFormat;
|
||||||
channelOrderName = GetChannelOrderName( imageFormat.image_channel_order );
|
error = clGetImageInfo(image, CL_IMAGE_FORMAT, sizeof(imageFormat),
|
||||||
if(channelOrderName && strlen(channelOrderName)) {
|
&imageFormat, NULL);
|
||||||
// replace CL_* with CLK_*
|
test_error(error, "Failed to get image format");
|
||||||
sprintf(channelOrderConstKernelLine, channelOrderConstLine, &channelOrderName[3]);
|
|
||||||
|
const char *imageType = 0;
|
||||||
|
bool doArraySize = false;
|
||||||
|
bool doImageWidth = false;
|
||||||
|
bool doImageHeight = false;
|
||||||
|
bool doImageChannelDataType = false;
|
||||||
|
bool doImageChannelOrder = false;
|
||||||
|
bool doImageDim = false;
|
||||||
|
bool doNumSamples = false;
|
||||||
|
bool doMSAA = false;
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
imageType = "image2d_depth_t";
|
||||||
|
doImageWidth = true;
|
||||||
|
doImageHeight = true;
|
||||||
|
doImageChannelDataType = true;
|
||||||
|
doImageChannelOrder = true;
|
||||||
|
doImageDim = true;
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
|
imageType = "image2d_array_depth_t";
|
||||||
|
doImageWidth = true;
|
||||||
|
doImageHeight = true;
|
||||||
|
doArraySize = true;
|
||||||
|
doImageChannelDataType = true;
|
||||||
|
doImageChannelOrder = true;
|
||||||
|
doImageDim = true;
|
||||||
|
doArraySize = true;
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_2D_MULTISAMPLE:
|
||||||
|
doNumSamples = true;
|
||||||
|
doMSAA = true;
|
||||||
|
if (format.formattype == GL_DEPTH_COMPONENT)
|
||||||
|
{
|
||||||
|
doImageWidth = true;
|
||||||
|
imageType = "image2d_msaa_depth_t";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageType = "image2d_msaa_t";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
|
||||||
|
doMSAA = true;
|
||||||
|
if (format.formattype == GL_DEPTH_COMPONENT)
|
||||||
|
{
|
||||||
|
doImageWidth = true;
|
||||||
|
imageType = "image2d_msaa_array_depth_t";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
imageType = "image2d_array_msaa_t";
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Create a program to run against
|
|
||||||
sprintf(programSrc,
|
|
||||||
methodTestKernelPattern,
|
|
||||||
( doMSAA ) ? enableMSAAKernelLine : "",
|
|
||||||
imageType,
|
|
||||||
( doArraySize ) ? arraySizeKernelLine : "",
|
|
||||||
( doImageWidth ) ? imageWidthKernelLine : "",
|
|
||||||
( doImageHeight ) ? imageHeightKernelLine : "",
|
|
||||||
( doImageChannelDataType ) ? channelTypeKernelLine : "",
|
|
||||||
( doImageChannelDataType ) ? channelTypeConstKernelLine : "",
|
|
||||||
( doImageChannelOrder ) ? channelOrderKernelLine : "",
|
|
||||||
( doImageChannelOrder ) ? channelOrderConstKernelLine : "",
|
|
||||||
( doImageDim ) ? imageDimKernelLine : "",
|
|
||||||
( doImageDim && doImageWidth ) ? imageWidthDimKernelLine : "",
|
|
||||||
( doImageDim && doImageHeight ) ? imageHeightDimKernelLine : "",
|
|
||||||
( doNumSamples ) ? numSamplesKernelLine : "");
|
|
||||||
|
|
||||||
|
|
||||||
//log_info("-----------------------------------\n%s\n", programSrc);
|
char channelTypeConstKernelLine[512] = { 0 };
|
||||||
error = clFinish(queue);
|
char channelOrderConstKernelLine[512] = { 0 };
|
||||||
if (error)
|
const char *channelTypeName = 0;
|
||||||
print_error(error, "clFinish failed.\n");
|
const char *channelOrderName = 0;
|
||||||
|
if (doImageChannelDataType)
|
||||||
|
{
|
||||||
|
channelTypeName =
|
||||||
|
GetChannelTypeName(imageFormat.image_channel_data_type);
|
||||||
|
if (channelTypeName && strlen(channelTypeName))
|
||||||
|
{
|
||||||
|
// replace CL_* with CLK_*
|
||||||
|
sprintf(channelTypeConstKernelLine, channelTypeConstLine,
|
||||||
|
&channelTypeName[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (doImageChannelOrder)
|
||||||
|
{
|
||||||
|
channelOrderName = GetChannelOrderName(imageFormat.image_channel_order);
|
||||||
|
if (channelOrderName && strlen(channelOrderName))
|
||||||
|
{
|
||||||
|
// replace CL_* with CLK_*
|
||||||
|
sprintf(channelOrderConstKernelLine, channelOrderConstLine,
|
||||||
|
&channelOrderName[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a program to run against
|
||||||
|
sprintf(programSrc, methodTestKernelPattern,
|
||||||
|
(doMSAA) ? enableMSAAKernelLine : "", imageType,
|
||||||
|
(doArraySize) ? arraySizeKernelLine : "",
|
||||||
|
(doImageWidth) ? imageWidthKernelLine : "",
|
||||||
|
(doImageHeight) ? imageHeightKernelLine : "",
|
||||||
|
(doImageChannelDataType) ? channelTypeKernelLine : "",
|
||||||
|
(doImageChannelDataType) ? channelTypeConstKernelLine : "",
|
||||||
|
(doImageChannelOrder) ? channelOrderKernelLine : "",
|
||||||
|
(doImageChannelOrder) ? channelOrderConstKernelLine : "",
|
||||||
|
(doImageDim) ? imageDimKernelLine : "",
|
||||||
|
(doImageDim && doImageWidth) ? imageWidthDimKernelLine : "",
|
||||||
|
(doImageDim && doImageHeight) ? imageHeightDimKernelLine : "",
|
||||||
|
(doNumSamples) ? numSamplesKernelLine : "");
|
||||||
|
|
||||||
|
|
||||||
|
// log_info("-----------------------------------\n%s\n", programSrc);
|
||||||
|
error = clFinish(queue);
|
||||||
|
if (error) print_error(error, "clFinish failed.\n");
|
||||||
const char *ptr = programSrc;
|
const char *ptr = programSrc;
|
||||||
error = create_single_kernel_helper( context, &program, &kernel, 1, &ptr, "sample_kernel" );
|
error = create_single_kernel_helper(context, &program, &kernel, 1, &ptr,
|
||||||
test_error( error, "Unable to create kernel to test against" );
|
"sample_kernel");
|
||||||
|
test_error(error, "Unable to create kernel to test against");
|
||||||
|
|
||||||
// Create an output buffer
|
// Create an output buffer
|
||||||
outDataBuffer = clCreateBuffer(context, CL_MEM_READ_WRITE,
|
outDataBuffer = clCreateBuffer(context, CL_MEM_READ_WRITE,
|
||||||
sizeof(outKernelData), NULL, &error);
|
sizeof(outKernelData), NULL, &error);
|
||||||
test_error( error, "Unable to create output buffer" );
|
test_error(error, "Unable to create output buffer");
|
||||||
|
|
||||||
// Set up arguments and run
|
// Set up arguments and run
|
||||||
error = clSetKernelArg( kernel, 0, sizeof( image ), &image );
|
error = clSetKernelArg(kernel, 0, sizeof(image), &image);
|
||||||
test_error( error, "Unable to set kernel argument" );
|
test_error(error, "Unable to set kernel argument");
|
||||||
error = clSetKernelArg( kernel, 1, sizeof( outDataBuffer ), &outDataBuffer );
|
error = clSetKernelArg(kernel, 1, sizeof(outDataBuffer), &outDataBuffer);
|
||||||
test_error( error, "Unable to set kernel argument" );
|
test_error(error, "Unable to set kernel argument");
|
||||||
|
|
||||||
// Finish and Acquire.
|
// Finish and Acquire.
|
||||||
glFinish();
|
glFinish();
|
||||||
@@ -294,119 +316,155 @@ int test_image_format_methods( cl_device_id device, cl_context context, cl_comma
|
|||||||
|
|
||||||
size_t threads[1] = { 1 }, localThreads[1] = { 1 };
|
size_t threads[1] = { 1 }, localThreads[1] = { 1 };
|
||||||
|
|
||||||
error = clEnqueueNDRangeKernel( queue, kernel, 1, NULL, threads, localThreads, 0, NULL, NULL );
|
error = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, threads,
|
||||||
test_error( error, "Unable to run kernel" );
|
localThreads, 0, NULL, NULL);
|
||||||
|
test_error(error, "Unable to run kernel");
|
||||||
|
|
||||||
error = clEnqueueReadBuffer( queue, outDataBuffer, CL_TRUE, 0, sizeof( outKernelData ), &outKernelData, 0, NULL, NULL );
|
error = clEnqueueReadBuffer(queue, outDataBuffer, CL_TRUE, 0,
|
||||||
test_error( error, "Unable to read data buffer" );
|
sizeof(outKernelData), &outKernelData, 0, NULL,
|
||||||
|
NULL);
|
||||||
|
test_error(error, "Unable to read data buffer");
|
||||||
|
|
||||||
// Verify the results now
|
// Verify the results now
|
||||||
if( doImageWidth )
|
if (doImageWidth) result |= verify(width, outKernelData.width, "width");
|
||||||
result |= verify(width, outKernelData.width, "width");
|
if (doImageHeight) result |= verify(height, outKernelData.height, "height");
|
||||||
if( doImageHeight)
|
if (doImageDim && doImageWidth)
|
||||||
result |= verify(height, outKernelData.height, "height");
|
result |=
|
||||||
if( doImageDim && doImageWidth )
|
verify(width, outKernelData.widthDim, "width from get_image_dim");
|
||||||
result |= verify(width, outKernelData.widthDim, "width from get_image_dim");
|
if (doImageDim && doImageHeight)
|
||||||
if( doImageDim && doImageHeight )
|
result |= verify(height, outKernelData.heightDim,
|
||||||
result |= verify(height, outKernelData.heightDim, "height from get_image_dim");
|
"height from get_image_dim");
|
||||||
if( doImageChannelDataType )
|
if (doImageChannelDataType)
|
||||||
result |= verify(outKernelData.channelType, outKernelData.expectedChannelType, channelTypeName);
|
result |= verify(outKernelData.channelType,
|
||||||
if( doImageChannelOrder )
|
outKernelData.expectedChannelType, channelTypeName);
|
||||||
result |= verify(outKernelData.channelOrder, outKernelData.expectedChannelOrder, channelOrderName);
|
if (doImageChannelOrder)
|
||||||
if( doArraySize )
|
result |= verify(outKernelData.channelOrder,
|
||||||
result |= verify(arraySize, outKernelData.arraySize, "array size");
|
outKernelData.expectedChannelOrder, channelOrderName);
|
||||||
if( doNumSamples )
|
if (doArraySize)
|
||||||
result |= verify(samples, outKernelData.numSamples, "samples");
|
result |= verify(arraySize, outKernelData.arraySize, "array size");
|
||||||
if(result) {
|
if (doNumSamples)
|
||||||
log_error("Test image methods failed");
|
result |= verify(samples, outKernelData.numSamples, "samples");
|
||||||
}
|
if (result)
|
||||||
|
{
|
||||||
|
log_error("Test image methods failed");
|
||||||
|
}
|
||||||
|
|
||||||
clEventWrapper event;
|
clEventWrapper event;
|
||||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &image, 0, NULL, &event );
|
error = (*clEnqueueReleaseGLObjects_ptr)(queue, 1, &image, 0, NULL, &event);
|
||||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||||
|
|
||||||
error = clWaitForEvents( 1, &event );
|
error = clWaitForEvents(1, &event);
|
||||||
test_error(error, "clWaitForEvents failed");
|
test_error(error, "clWaitForEvents failed");
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_image_methods_depth( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ){
|
int test_image_methods_depth(cl_device_id device, cl_context context,
|
||||||
if (!is_extension_available(device, "cl_khr_gl_depth_images")) {
|
cl_command_queue queue, int numElements)
|
||||||
log_info("Test not run because 'cl_khr_gl_depth_images' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
if (!is_extension_available(device, "cl_khr_gl_depth_images"))
|
||||||
}
|
{
|
||||||
|
log_info("Test not run because 'cl_khr_gl_depth_images' extension is "
|
||||||
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
GLenum depth_targets[] = {GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY};
|
GLenum depth_targets[] = { GL_TEXTURE_2D, GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(depth_targets) / sizeof(depth_targets[0]);
|
size_t ntargets = sizeof(depth_targets) / sizeof(depth_targets[0]);
|
||||||
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 5;
|
const size_t nsizes = 5;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, maxTextureLayers = 16, size;
|
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096,
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
maxTextureLayers = 16, size;
|
||||||
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
||||||
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
|
|
||||||
size = min(maxTextureSize, maxTextureRectangleSize);
|
size = min(maxTextureSize, maxTextureRectangleSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
|
||||||
for(size_t itarget = 0; itarget < ntargets; ++itarget) {
|
|
||||||
for(size_t iformat = 0; iformat < nformats; ++iformat)
|
|
||||||
result |= test_image_format_methods(device, context, queue, sizes[i].width, sizes[i].height, (depth_targets[itarget] == GL_TEXTURE_2D_ARRAY) ? sizes[i].depth: 1, 0,
|
|
||||||
depth_targets[itarget], depth_formats[iformat], seed );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
int test_image_methods_multisample( cl_device_id device, cl_context context, cl_command_queue queue, int numElements ){
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing")) {
|
{
|
||||||
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is not supported by the tested device\n");
|
for (size_t itarget = 0; itarget < ntargets; ++itarget)
|
||||||
return 0;
|
{
|
||||||
}
|
for (size_t iformat = 0; iformat < nformats; ++iformat)
|
||||||
|
result |= test_image_format_methods(
|
||||||
int result = 0;
|
device, context, queue, sizes[i].width, sizes[i].height,
|
||||||
GLenum targets[] = {GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_2D_MULTISAMPLE_ARRAY};
|
(depth_targets[itarget] == GL_TEXTURE_2D_ARRAY)
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
? sizes[i].depth
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
: 1,
|
||||||
|
0, depth_targets[itarget], depth_formats[iformat], seed);
|
||||||
const size_t nsizes = 5;
|
}
|
||||||
sizevec_t sizes[nsizes];
|
}
|
||||||
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
return result;
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
}
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
|
||||||
|
int test_image_methods_multisample(cl_device_id device, cl_context context,
|
||||||
RandomSeed seed( gRandomSeed );
|
cl_command_queue queue, int numElements)
|
||||||
|
{
|
||||||
// Generate some random sizes (within reasonable ranges)
|
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing"))
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
{
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is "
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
"not supported by the tested device\n");
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = 0;
|
||||||
|
GLenum targets[] = { GL_TEXTURE_2D_MULTISAMPLE,
|
||||||
|
GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
|
||||||
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
|
const size_t nsizes = 5;
|
||||||
|
sizevec_t sizes[nsizes];
|
||||||
|
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
||||||
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
|
// Generate some random sizes (within reasonable ranges)
|
||||||
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
|
{
|
||||||
|
sizes[i].width =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
|
{
|
||||||
|
for (size_t itarget = 0; itarget < ntargets; ++itarget)
|
||||||
|
{
|
||||||
|
for (size_t iformat = 0; iformat < nformats; ++iformat)
|
||||||
|
{
|
||||||
|
GLint samples = get_gl_max_samples(
|
||||||
|
targets[itarget], common_formats[iformat].internal);
|
||||||
|
result |= test_image_format_methods(
|
||||||
|
device, context, queue, sizes[i].width, sizes[i].height,
|
||||||
|
(targets[ntargets] == GL_TEXTURE_2D_MULTISAMPLE_ARRAY)
|
||||||
|
? sizes[i].depth
|
||||||
|
: 1,
|
||||||
|
samples, targets[itarget], common_formats[iformat], seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
|
||||||
|
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
|
||||||
for(size_t itarget = 0; itarget < ntargets; ++itarget) {
|
|
||||||
for(size_t iformat = 0; iformat < nformats; ++iformat) {
|
|
||||||
GLint samples = get_gl_max_samples(targets[itarget], common_formats[iformat].internal);
|
|
||||||
result |= test_image_format_methods(device, context, queue, sizes[i].width, sizes[i].height, (targets[ntargets] == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) ? sizes[i].depth: 1,
|
|
||||||
samples, targets[itarget], common_formats[iformat], seed );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -28,114 +28,116 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
GLint maxTextureSize = 4096, maxTextureBufferSize = 4096, size;
|
GLint maxTextureSize = 4096, maxTextureBufferSize = 4096, size;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTextureBufferSize);
|
glGetIntegerv(GL_MAX_TEXTURE_BUFFER_SIZE, &maxTextureBufferSize);
|
||||||
|
|
||||||
size = min(maxTextureSize, maxTextureBufferSize);
|
size = min(maxTextureSize, maxTextureBufferSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = 1;
|
sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
sizes[i].depth = 1;
|
sizes[i].height = 1;
|
||||||
}
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_1D( cl_device_id device, cl_context context,
|
int test_images_read_1D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_1D };
|
GLenum targets[] = { GL_TEXTURE_1D };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_1D( cl_device_id device, cl_context context,
|
int test_images_write_1D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_1D };
|
GLenum targets[] = { GL_TEXTURE_1D };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
int test_images_1D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_1D };
|
GLenum targets[] = { GL_TEXTURE_1D };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common( device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_texturebuffer( cl_device_id device, cl_context context,
|
int test_images_read_texturebuffer(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_texturebuffer( cl_device_id device, cl_context context,
|
int test_images_write_texturebuffer(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_texturebuffer_getinfo( cl_device_id device, cl_context context,
|
int test_images_texturebuffer_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
GLenum targets[] = { GL_TEXTURE_BUFFER };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_test_size_descriptors(sizes, nsizes);
|
calc_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common( device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,75 +16,79 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
void calc_1D_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_1D_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
sizes[i].width =
|
||||||
sizes[i].depth = 1;
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_1Darray( cl_device_id device, cl_context context,
|
int test_images_read_1Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int )
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_1D_array_size_descriptors(sizes, nsizes);
|
calc_1D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_1Darray( cl_device_id device, cl_context context,
|
int test_images_write_1Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_1D_array_size_descriptors(sizes, nsizes);
|
calc_1D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
int test_images_1Darray_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int )
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_1D_array_size_descriptors(sizes, nsizes);
|
calc_1D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common(device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
@@ -31,76 +31,77 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_2D_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_2D_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, size;
|
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, size;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
||||||
|
|
||||||
size = min(maxTextureSize, maxTextureRectangleSize);
|
size = min(maxTextureSize, maxTextureRectangleSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
sizes[i].depth = 1;
|
sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calc_cube_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_cube_test_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxQubeMapSize = 4096;
|
GLint maxQubeMapSize = 4096;
|
||||||
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxQubeMapSize);
|
glGetIntegerv(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &maxQubeMapSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = sizes[i].height = random_in_range( 2, min(maxQubeMapSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].depth = 1;
|
sizes[i].width = sizes[i].height =
|
||||||
}
|
random_in_range(2, min(maxQubeMapSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2D( cl_device_id device, cl_context context,
|
int test_images_read_2D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_test_size_descriptors(sizes, nsizes);
|
calc_2D_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_cube( cl_device_id device, cl_context context,
|
int test_images_read_cube(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = {
|
GLenum targets[] = {
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
};
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z };
|
|
||||||
|
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_cube_test_size_descriptors(sizes, nsizes);
|
calc_cube_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
@@ -108,81 +109,77 @@ int test_images_read_cube( cl_device_id device, cl_context context,
|
|||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
int test_images_write( cl_device_id device, cl_context context,
|
int test_images_write(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_test_size_descriptors(sizes, nsizes);
|
calc_2D_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_cube( cl_device_id device, cl_context context,
|
int test_images_write_cube(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = {
|
GLenum targets[] = {
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
};
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
||||||
};
|
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_cube_test_size_descriptors(sizes, nsizes);
|
calc_cube_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark _2D get info tests
|
#pragma mark _2D get info tests
|
||||||
|
|
||||||
int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
int test_images_2D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_test_size_descriptors(sizes, nsizes);
|
calc_2D_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common(device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
int test_images_cube_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = {
|
GLenum targets[] = {
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_X, GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
GL_TEXTURE_CUBE_MAP_POSITIVE_Z, GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Z,
|
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
};
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
};
|
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_cube_test_size_descriptors(sizes, nsizes);
|
calc_cube_test_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common(device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -28,66 +28,71 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_2D_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_2D_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
sizes[i].width =
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2Darray( cl_device_id device, cl_context context,
|
int test_images_read_2Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int )
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_array_size_descriptors(sizes, nsizes);
|
calc_2D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_2Darray( cl_device_id device, cl_context context,
|
int test_images_write_2Darray(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
// FIXME: Query for 2D image array write support.
|
// FIXME: Query for 2D image array write support.
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_array_size_descriptors(sizes, nsizes);
|
calc_2D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
int test_images_2Darray_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int )
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_array_size_descriptors(sizes, nsizes);
|
calc_2D_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common(device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
@@ -31,77 +31,85 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_3D_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_3D_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
GLint maxTextureSize = 2048;
|
GLint maxTextureSize = 2048;
|
||||||
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
sizes[i].width =
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_3D( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
int test_images_read_3D(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_3D };
|
GLenum targets[] = { GL_TEXTURE_3D };
|
||||||
size_t ntargets = 1;
|
size_t ntargets = 1;
|
||||||
|
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_3D_size_descriptors(sizes, nsizes);
|
calc_3D_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, common_formats,
|
return test_images_read_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma marm _3D write test
|
#pragma marm _3D write test
|
||||||
|
|
||||||
int test_images_write_3D( cl_device_id device, cl_context context,
|
int test_images_write_3D(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
// TODO: Perhaps the expected behavior is to FAIL if 3D images are
|
// TODO: Perhaps the expected behavior is to FAIL if 3D images are
|
||||||
// unsupported?
|
// unsupported?
|
||||||
|
|
||||||
if (!is_extension_available(device, "cl_khr_3d_image_writes")) {
|
if (!is_extension_available(device, "cl_khr_3d_image_writes"))
|
||||||
log_info("This device does not support 3D image writes. Skipping test.\n");
|
{
|
||||||
return 0;
|
log_info(
|
||||||
}
|
"This device does not support 3D image writes. Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_3D };
|
GLenum targets[] = { GL_TEXTURE_3D };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_3D_size_descriptors(sizes, nsizes);
|
calc_3D_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, common_formats,
|
return test_images_write_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark _3D get info test
|
#pragma mark _3D get info test
|
||||||
|
|
||||||
int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
int test_images_3D_getinfo(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum targets[] = { GL_TEXTURE_3D };
|
GLenum targets[] = { GL_TEXTURE_3D };
|
||||||
size_t ntargets = 1;
|
size_t ntargets = 1;
|
||||||
|
|
||||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_3D_size_descriptors(sizes, nsizes);
|
calc_3D_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_get_info_common(device, context, queue, common_formats,
|
return test_images_get_info_common(device, context, queue, common_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes,
|
||||||
|
nsizes);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
@@ -32,129 +32,140 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_depth_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_depth_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, size;
|
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, size;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
||||||
|
|
||||||
size = min(maxTextureSize, maxTextureRectangleSize);
|
size = min(maxTextureSize, maxTextureRectangleSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
sizes[i].depth = 1;
|
sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calc_depth_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_depth_array_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096, maxTextureLayers = 16, size;
|
GLint maxTextureSize = 4096, maxTextureRectangleSize = 4096,
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
maxTextureLayers = 16, size;
|
||||||
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
glGetIntegerv(GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &maxTextureRectangleSize);
|
||||||
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
|
|
||||||
size = min(maxTextureSize, maxTextureRectangleSize);
|
size = min(maxTextureSize, maxTextureRectangleSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(size, 1<<(i+4)), seed );
|
sizes[i].width = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
sizes[i].height = random_in_range(2, min(size, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2D_depth( cl_device_id device, cl_context context,
|
int test_images_read_2D_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_depth_images")) {
|
if (!is_extension_available(device, "cl_khr_gl_depth_images"))
|
||||||
log_info("Test not run because 'cl_khr_gl_depth_images' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_depth_images' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_depth_size_descriptors(sizes, nsizes);
|
calc_depth_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, depth_formats,
|
return test_images_read_common(device, context, queue, depth_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark _2D depth write tests
|
#pragma mark _2D depth write tests
|
||||||
|
|
||||||
|
|
||||||
int test_images_write_2D_depth( cl_device_id device, cl_context context,
|
int test_images_write_2D_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_depth_images")) {
|
if (!is_extension_available(device, "cl_khr_gl_depth_images"))
|
||||||
log_info("Test not run because 'cl_khr_gl_depth_images' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_depth_images' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_depth_size_descriptors(sizes, nsizes);
|
calc_depth_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, depth_formats,
|
return test_images_write_common(device, context, queue, depth_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2Darray_depth( cl_device_id device, cl_context context,
|
int test_images_read_2Darray_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int )
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_depth_images")) {
|
if (!is_extension_available(device, "cl_khr_gl_depth_images"))
|
||||||
log_info("Test not run because 'cl_khr_gl_depth_images' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_depth_images' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_depth_array_size_descriptors(sizes, nsizes);
|
calc_depth_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_read_common(device, context, queue, depth_formats,
|
return test_images_read_common(device, context, queue, depth_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes);
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_write_2Darray_depth( cl_device_id device, cl_context context,
|
int test_images_write_2Darray_depth(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_depth_images")) {
|
if (!is_extension_available(device, "cl_khr_gl_depth_images"))
|
||||||
log_info("Test not run because 'cl_khr_gl_depth_images' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_depth_images' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// FIXME: Query for 2D image array write support.
|
// FIXME: Query for 2D image array write support.
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
size_t nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
|
|
||||||
const size_t nsizes = 6;
|
const size_t nsizes = 6;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_depth_array_size_descriptors(sizes, nsizes);
|
calc_depth_array_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
return test_images_write_common( device, context, queue, depth_formats,
|
return test_images_write_common(device, context, queue, depth_formats,
|
||||||
nformats, targets, ntargets, sizes, nsizes );
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,74 +16,71 @@
|
|||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int supportsHalf(cl_context context, bool* supports_half);
|
extern int supportsHalf(cl_context context, bool *supports_half);
|
||||||
|
|
||||||
static int test_image_info( cl_context context, cl_command_queue queue,
|
static int test_image_info(cl_context context, cl_command_queue queue,
|
||||||
GLenum glTarget, GLuint glTexture, size_t imageWidth, size_t imageHeight,
|
GLenum glTarget, GLuint glTexture, size_t imageWidth,
|
||||||
size_t imageDepth, cl_image_format *outFormat, ExplicitType *outType,
|
size_t imageHeight, size_t imageDepth,
|
||||||
void **outResultBuffer )
|
cl_image_format *outFormat, ExplicitType *outType,
|
||||||
|
void **outResultBuffer)
|
||||||
{
|
{
|
||||||
clMemWrapper streams[ 2 ];
|
clMemWrapper streams[2];
|
||||||
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
// Create a CL image from the supplied GL texture
|
// Create a CL image from the supplied GL texture
|
||||||
streams[ 0 ] = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
streams[0] = (*clCreateFromGLTexture_ptr)(context, CL_MEM_READ_ONLY,
|
||||||
glTarget, 0, glTexture, &error );
|
glTarget, 0, glTexture, &error);
|
||||||
if( error != CL_SUCCESS )
|
if (error != CL_SUCCESS)
|
||||||
{
|
{
|
||||||
print_error( error, "Unable to create CL image from GL texture" );
|
print_error(error, "Unable to create CL image from GL texture");
|
||||||
GLint fmt;
|
GLint fmt;
|
||||||
glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
glGetTexLevelParameteriv(glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt);
|
||||||
log_error( " Supplied GL texture was format %s\n", GetGLFormatName( fmt ) );
|
log_error(" Supplied GL texture was format %s\n",
|
||||||
return error;
|
GetGLFormatName(fmt));
|
||||||
}
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
// Determine data type and format that CL came up with
|
// Determine data type and format that CL came up with
|
||||||
error = clGetImageInfo( streams[ 0 ], CL_IMAGE_FORMAT,
|
error = clGetImageInfo(streams[0], CL_IMAGE_FORMAT, sizeof(cl_image_format),
|
||||||
sizeof( cl_image_format ), outFormat, NULL );
|
outFormat, NULL);
|
||||||
test_error( error, "Unable to get CL image format" );
|
test_error(error, "Unable to get CL image format");
|
||||||
|
|
||||||
cl_gl_object_type object_type;
|
cl_gl_object_type object_type;
|
||||||
switch (glTarget) {
|
switch (glTarget)
|
||||||
case GL_TEXTURE_1D:
|
{
|
||||||
object_type = CL_GL_OBJECT_TEXTURE1D;
|
case GL_TEXTURE_1D: object_type = CL_GL_OBJECT_TEXTURE1D; break;
|
||||||
break;
|
case GL_TEXTURE_BUFFER:
|
||||||
case GL_TEXTURE_BUFFER:
|
object_type = CL_GL_OBJECT_TEXTURE_BUFFER;
|
||||||
object_type = CL_GL_OBJECT_TEXTURE_BUFFER;
|
break;
|
||||||
break;
|
case GL_TEXTURE_1D_ARRAY:
|
||||||
case GL_TEXTURE_1D_ARRAY:
|
object_type = CL_GL_OBJECT_TEXTURE1D_ARRAY;
|
||||||
object_type = CL_GL_OBJECT_TEXTURE1D_ARRAY;
|
break;
|
||||||
break;
|
case GL_TEXTURE_2D:
|
||||||
case GL_TEXTURE_2D:
|
case GL_TEXTURE_RECTANGLE_EXT:
|
||||||
case GL_TEXTURE_RECTANGLE_EXT:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
object_type = CL_GL_OBJECT_TEXTURE2D;
|
||||||
object_type = CL_GL_OBJECT_TEXTURE2D;
|
break;
|
||||||
break;
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
object_type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
|
||||||
object_type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
|
break;
|
||||||
break;
|
case GL_TEXTURE_3D: object_type = CL_GL_OBJECT_TEXTURE3D; break;
|
||||||
case GL_TEXTURE_3D:
|
default: log_error("Unsupported texture target."); return 1;
|
||||||
object_type = CL_GL_OBJECT_TEXTURE3D;
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log_error("Unsupported texture target.");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return CheckGLObjectInfo(streams[0], object_type, glTexture, glTarget, 0);
|
return CheckGLObjectInfo(streams[0], object_type, glTexture, glTarget, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int test_image_format_get_info(cl_context context,
|
static int test_image_format_get_info(cl_context context,
|
||||||
@@ -92,110 +89,119 @@ static int test_image_format_get_info(cl_context context,
|
|||||||
GLenum target, const format *fmt,
|
GLenum target, const format *fmt,
|
||||||
MTdata data)
|
MTdata data)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
// If we're testing a half float format, then we need to determine the
|
// If we're testing a half float format, then we need to determine the
|
||||||
// rounding mode of this machine. Punt if we fail to do so.
|
// rounding mode of this machine. Punt if we fail to do so.
|
||||||
|
|
||||||
if( fmt->type == kHalf )
|
if (fmt->type == kHalf)
|
||||||
{
|
{
|
||||||
if( DetectFloatToHalfRoundingMode(queue) )
|
if (DetectFloatToHalfRoundingMode(queue)) return 0;
|
||||||
return 0;
|
bool supports_half = false;
|
||||||
bool supports_half = false;
|
error = supportsHalf(context, &supports_half);
|
||||||
error = supportsHalf(context, &supports_half);
|
if (error != 0) return error;
|
||||||
if( error != 0 )
|
if (!supports_half) return 0;
|
||||||
return error;
|
|
||||||
if (!supports_half) return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t w = width, h = height, d = depth;
|
|
||||||
|
|
||||||
// Unpack the format and use it, along with the target, to create an
|
|
||||||
// appropriate GL texture.
|
|
||||||
|
|
||||||
GLenum gl_fmt = fmt->formattype;
|
|
||||||
GLenum gl_internal_fmt = fmt->internal;
|
|
||||||
GLenum gl_type = fmt->datatype;
|
|
||||||
ExplicitType type = fmt->type;
|
|
||||||
|
|
||||||
glTextureWrapper texture;
|
|
||||||
glBufferWrapper glbuf;
|
|
||||||
|
|
||||||
// If we're testing a half float format, then we need to determine the
|
|
||||||
// rounding mode of this machine. Punt if we fail to do so.
|
|
||||||
|
|
||||||
if( fmt->type == kHalf )
|
|
||||||
if( DetectFloatToHalfRoundingMode(queue) )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Use the correct texture creation function depending on the target, and
|
|
||||||
// adjust width, height, depth as appropriate so subsequent size calculations
|
|
||||||
// succeed.
|
|
||||||
|
|
||||||
switch (target) {
|
|
||||||
case GL_TEXTURE_1D:
|
|
||||||
h = 1; d = 1;
|
|
||||||
CreateGLTexture1D( width, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &error, false, data );
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_BUFFER:
|
|
||||||
h = 1; d = 1;
|
|
||||||
CreateGLTextureBuffer( width, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &glbuf, &error, false, data );
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_1D_ARRAY:
|
|
||||||
d = 1;
|
|
||||||
CreateGLTexture1DArray( width, height, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &error, false, data );
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_RECTANGLE_EXT:
|
|
||||||
case GL_TEXTURE_2D:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
|
||||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
|
||||||
d = 1;
|
|
||||||
CreateGLTexture2D( width, height, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &error, false, data );
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_2D_ARRAY:
|
|
||||||
CreateGLTexture2DArray( width, height, depth, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &error, false, data );
|
|
||||||
break;
|
|
||||||
case GL_TEXTURE_3D:
|
|
||||||
d = 1;
|
|
||||||
CreateGLTexture3D( width, height, depth, target, gl_fmt,
|
|
||||||
gl_internal_fmt, gl_type, type, &texture, &error, data, false );
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log_error("Unsupported texture target.\n");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( error == -2 ) {
|
|
||||||
log_info("OpenGL texture couldn't be created, because a texture is too big. Skipping test.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( error != 0 ) {
|
|
||||||
if ((gl_fmt == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport())) {
|
|
||||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. "
|
|
||||||
"Skipping test.\n");
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return error;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
cl_image_format clFormat;
|
size_t w = width, h = height, d = depth;
|
||||||
ExplicitType actualType;
|
|
||||||
char *outBuffer;
|
|
||||||
|
|
||||||
// Perform the info check:
|
// Unpack the format and use it, along with the target, to create an
|
||||||
return test_image_info( context, queue, target, texture, w, h, d, &clFormat,
|
// appropriate GL texture.
|
||||||
&actualType, (void **)&outBuffer );
|
|
||||||
|
GLenum gl_fmt = fmt->formattype;
|
||||||
|
GLenum gl_internal_fmt = fmt->internal;
|
||||||
|
GLenum gl_type = fmt->datatype;
|
||||||
|
ExplicitType type = fmt->type;
|
||||||
|
|
||||||
|
glTextureWrapper texture;
|
||||||
|
glBufferWrapper glbuf;
|
||||||
|
|
||||||
|
// If we're testing a half float format, then we need to determine the
|
||||||
|
// rounding mode of this machine. Punt if we fail to do so.
|
||||||
|
|
||||||
|
if (fmt->type == kHalf)
|
||||||
|
if (DetectFloatToHalfRoundingMode(queue)) return 1;
|
||||||
|
|
||||||
|
// Use the correct texture creation function depending on the target, and
|
||||||
|
// adjust width, height, depth as appropriate so subsequent size
|
||||||
|
// calculations succeed.
|
||||||
|
|
||||||
|
switch (target)
|
||||||
|
{
|
||||||
|
case GL_TEXTURE_1D:
|
||||||
|
h = 1;
|
||||||
|
d = 1;
|
||||||
|
CreateGLTexture1D(width, target, gl_fmt, gl_internal_fmt, gl_type,
|
||||||
|
type, &texture, &error, false, data);
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_BUFFER:
|
||||||
|
h = 1;
|
||||||
|
d = 1;
|
||||||
|
CreateGLTextureBuffer(width, target, gl_fmt, gl_internal_fmt,
|
||||||
|
gl_type, type, &texture, &glbuf, &error,
|
||||||
|
false, data);
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_1D_ARRAY:
|
||||||
|
d = 1;
|
||||||
|
CreateGLTexture1DArray(width, height, target, gl_fmt,
|
||||||
|
gl_internal_fmt, gl_type, type, &texture,
|
||||||
|
&error, false, data);
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_RECTANGLE_EXT:
|
||||||
|
case GL_TEXTURE_2D:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
|
||||||
|
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
|
||||||
|
d = 1;
|
||||||
|
CreateGLTexture2D(width, height, target, gl_fmt, gl_internal_fmt,
|
||||||
|
gl_type, type, &texture, &error, false, data);
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_2D_ARRAY:
|
||||||
|
CreateGLTexture2DArray(width, height, depth, target, gl_fmt,
|
||||||
|
gl_internal_fmt, gl_type, type, &texture,
|
||||||
|
&error, false, data);
|
||||||
|
break;
|
||||||
|
case GL_TEXTURE_3D:
|
||||||
|
d = 1;
|
||||||
|
CreateGLTexture3D(width, height, depth, target, gl_fmt,
|
||||||
|
gl_internal_fmt, gl_type, type, &texture, &error,
|
||||||
|
data, false);
|
||||||
|
break;
|
||||||
|
default: log_error("Unsupported texture target.\n"); return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error == -2)
|
||||||
|
{
|
||||||
|
log_info("OpenGL texture couldn't be created, because a texture is too "
|
||||||
|
"big. Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error != 0)
|
||||||
|
{
|
||||||
|
if ((gl_fmt == GL_RGBA_INTEGER_EXT)
|
||||||
|
&& (!CheckGLIntegerExtensionSupport()))
|
||||||
|
{
|
||||||
|
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. "
|
||||||
|
"Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cl_image_format clFormat;
|
||||||
|
ExplicitType actualType;
|
||||||
|
char *outBuffer;
|
||||||
|
|
||||||
|
// Perform the info check:
|
||||||
|
return test_image_info(context, queue, target, texture, w, h, d, &clFormat,
|
||||||
|
&actualType, (void **)&outBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_get_info_common(cl_device_id device, cl_context context,
|
int test_images_get_info_common(cl_device_id device, cl_context context,
|
||||||
@@ -204,60 +210,65 @@ int test_images_get_info_common(cl_device_id device, cl_context context,
|
|||||||
size_t ntargets, sizevec_t *sizes,
|
size_t ntargets, sizevec_t *sizes,
|
||||||
size_t nsizes)
|
size_t nsizes)
|
||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
RandomSeed seed(gRandomSeed);
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// First, ensure this device supports images.
|
// First, ensure this device supports images.
|
||||||
|
|
||||||
if (checkForImageSupport(device)) {
|
if (checkForImageSupport(device))
|
||||||
log_info("Device does not support images. Skipping test.\n");
|
{
|
||||||
return 0;
|
log_info("Device does not support images. Skipping test.\n");
|
||||||
}
|
return 0;
|
||||||
|
|
||||||
size_t fidx, tidx, sidx;
|
|
||||||
|
|
||||||
// Test each format on every target, every size.
|
|
||||||
|
|
||||||
for ( fidx = 0; fidx < nformats; fidx++ ) {
|
|
||||||
for ( tidx = 0; tidx < ntargets; tidx++ ) {
|
|
||||||
|
|
||||||
if ( formats[ fidx ].datatype == GL_UNSIGNED_INT_2_10_10_10_REV )
|
|
||||||
{
|
|
||||||
// Check if the RGB 101010 format is supported
|
|
||||||
if ( is_rgb_101010_supported( context, targets[ tidx ] ) == 0 )
|
|
||||||
break; // skip
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info( "Testing image info for GL format %s : %s : %s : %s\n",
|
|
||||||
GetGLTargetName( targets[ tidx ] ),
|
|
||||||
GetGLFormatName( formats[ fidx ].internal ),
|
|
||||||
GetGLBaseFormatName( formats[ fidx ].formattype ),
|
|
||||||
GetGLTypeName( formats[ fidx ].datatype ) );
|
|
||||||
|
|
||||||
for ( sidx = 0; sidx < nsizes; sidx++ ) {
|
|
||||||
|
|
||||||
// Test this format + size:
|
|
||||||
|
|
||||||
if ( test_image_format_get_info(context, queue,
|
|
||||||
sizes[sidx].width, sizes[sidx].height, sizes[sidx].depth,
|
|
||||||
targets[tidx], &formats[fidx], seed) )
|
|
||||||
{
|
|
||||||
// We land here in the event of test failure.
|
|
||||||
|
|
||||||
log_error( "ERROR: Image info test failed for %s : %s : %s : %s\n\n",
|
|
||||||
GetGLTargetName( targets[ tidx ] ),
|
|
||||||
GetGLFormatName( formats[ fidx ].internal ),
|
|
||||||
GetGLBaseFormatName( formats[ fidx ].formattype ),
|
|
||||||
GetGLTypeName( formats[ fidx ].datatype ) );
|
|
||||||
error++;
|
|
||||||
|
|
||||||
// Skip the other sizes for this format.
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return error;
|
size_t fidx, tidx, sidx;
|
||||||
|
|
||||||
|
// Test each format on every target, every size.
|
||||||
|
|
||||||
|
for (fidx = 0; fidx < nformats; fidx++)
|
||||||
|
{
|
||||||
|
for (tidx = 0; tidx < ntargets; tidx++)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (formats[fidx].datatype == GL_UNSIGNED_INT_2_10_10_10_REV)
|
||||||
|
{
|
||||||
|
// Check if the RGB 101010 format is supported
|
||||||
|
if (is_rgb_101010_supported(context, targets[tidx]) == 0)
|
||||||
|
break; // skip
|
||||||
|
}
|
||||||
|
|
||||||
|
log_info("Testing image info for GL format %s : %s : %s : %s\n",
|
||||||
|
GetGLTargetName(targets[tidx]),
|
||||||
|
GetGLFormatName(formats[fidx].internal),
|
||||||
|
GetGLBaseFormatName(formats[fidx].formattype),
|
||||||
|
GetGLTypeName(formats[fidx].datatype));
|
||||||
|
|
||||||
|
for (sidx = 0; sidx < nsizes; sidx++)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Test this format + size:
|
||||||
|
|
||||||
|
if (test_image_format_get_info(
|
||||||
|
context, queue, sizes[sidx].width, sizes[sidx].height,
|
||||||
|
sizes[sidx].depth, targets[tidx], &formats[fidx], seed))
|
||||||
|
{
|
||||||
|
// We land here in the event of test failure.
|
||||||
|
|
||||||
|
log_error("ERROR: Image info test failed for %s : %s : %s "
|
||||||
|
": %s\n\n",
|
||||||
|
GetGLTargetName(targets[tidx]),
|
||||||
|
GetGLFormatName(formats[fidx].internal),
|
||||||
|
GetGLBaseFormatName(formats[fidx].formattype),
|
||||||
|
GetGLTypeName(formats[fidx].datatype));
|
||||||
|
error++;
|
||||||
|
|
||||||
|
// Skip the other sizes for this format.
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -16,11 +16,11 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -29,90 +29,109 @@ using namespace std;
|
|||||||
|
|
||||||
void calc_2D_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_2D_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit texture size according to GL device properties
|
// Need to limit texture size according to GL device properties
|
||||||
GLint maxTextureSize = 4096;
|
GLint maxTextureSize = 4096;
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
sizes[i].width =
|
||||||
sizes[i].depth = 1;
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void calc_2D_array_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
void calc_2D_array_multisample_size_descriptors(sizevec_t* sizes, size_t nsizes)
|
||||||
{
|
{
|
||||||
// Need to limit array size according to GL device properties
|
// Need to limit array size according to GL device properties
|
||||||
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
GLint maxTextureLayers = 16, maxTextureSize = 4096;
|
||||||
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &maxTextureLayers);
|
||||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
|
||||||
|
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Generate some random sizes (within reasonable ranges)
|
// Generate some random sizes (within reasonable ranges)
|
||||||
for (size_t i = 0; i < nsizes; i++) {
|
for (size_t i = 0; i < nsizes; i++)
|
||||||
sizes[i].width = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
{
|
||||||
sizes[i].height = random_in_range( 2, min(maxTextureSize, 1<<(i+4)), seed );
|
sizes[i].width =
|
||||||
sizes[i].depth = random_in_range( 2, min(maxTextureLayers, 1<<(i+4)), seed );
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
}
|
sizes[i].height =
|
||||||
|
random_in_range(2, min(maxTextureSize, 1 << (i + 4)), seed);
|
||||||
|
sizes[i].depth =
|
||||||
|
random_in_range(2, min(maxTextureLayers, 1 << (i + 4)), seed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2D_multisample( cl_device_id device, cl_context context,
|
int test_images_read_2D_multisample(cl_device_id device, cl_context context,
|
||||||
cl_command_queue queue, int numElements )
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing")) {
|
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing"))
|
||||||
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
const size_t nsizes = 8;
|
const size_t nsizes = 8;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_multisample_size_descriptors(sizes, nsizes);
|
calc_2D_multisample_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
size_t nformats;
|
size_t nformats;
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_MULTISAMPLE };
|
GLenum targets[] = { GL_TEXTURE_2D_MULTISAMPLE };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
int ret_common = test_images_read_common(device, context, queue, common_formats, nformats, targets, ntargets, sizes, nsizes);
|
int ret_common =
|
||||||
|
test_images_read_common(device, context, queue, common_formats,
|
||||||
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
|
|
||||||
nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
int ret_depth = test_images_read_common(device, context, queue, depth_formats, nformats, targets, ntargets, sizes, nsizes);
|
int ret_depth =
|
||||||
|
test_images_read_common(device, context, queue, depth_formats, nformats,
|
||||||
|
targets, ntargets, sizes, nsizes);
|
||||||
|
|
||||||
return (ret_common) ? ret_common : ret_depth;
|
return (ret_common) ? ret_common : ret_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_images_read_2Darray_multisample( cl_device_id device, cl_context context,
|
int test_images_read_2Darray_multisample(cl_device_id device,
|
||||||
cl_command_queue queue, int )
|
cl_context context,
|
||||||
|
cl_command_queue queue, int)
|
||||||
{
|
{
|
||||||
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing")) {
|
if (!is_extension_available(device, "cl_khr_gl_msaa_sharing"))
|
||||||
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is not supported by the tested device\n");
|
{
|
||||||
return 0;
|
log_info("Test not run because 'cl_khr_gl_msaa_sharing' extension is "
|
||||||
}
|
"not supported by the tested device\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
|
|
||||||
const size_t nsizes = 4;
|
const size_t nsizes = 4;
|
||||||
sizevec_t sizes[nsizes];
|
sizevec_t sizes[nsizes];
|
||||||
calc_2D_array_multisample_size_descriptors(sizes, nsizes);
|
calc_2D_array_multisample_size_descriptors(sizes, nsizes);
|
||||||
|
|
||||||
size_t nformats;
|
size_t nformats;
|
||||||
|
|
||||||
GLenum targets[] = { GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
|
GLenum targets[] = { GL_TEXTURE_2D_MULTISAMPLE_ARRAY };
|
||||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||||
|
|
||||||
nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||||
int ret_common = test_images_read_common(device, context, queue, common_formats, nformats, targets, ntargets, sizes, nsizes);
|
int ret_common =
|
||||||
|
test_images_read_common(device, context, queue, common_formats,
|
||||||
|
nformats, targets, ntargets, sizes, nsizes);
|
||||||
|
|
||||||
nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
nformats = sizeof(depth_formats) / sizeof(depth_formats[0]);
|
||||||
int ret_depth = test_images_read_common(device, context, queue, depth_formats, nformats, targets, ntargets, sizes, nsizes);
|
int ret_depth =
|
||||||
|
test_images_read_common(device, context, queue, depth_formats, nformats,
|
||||||
|
targets, ntargets, sizes, nsizes);
|
||||||
|
|
||||||
return (ret_common) ? ret_common : ret_depth;
|
return (ret_common) ? ret_common : ret_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -15,93 +15,102 @@
|
|||||||
//
|
//
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
|
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined (__linux__)
|
#if defined(__linux__)
|
||||||
GLboolean
|
GLboolean gluCheckExtension(const GLubyte *extension, const GLubyte *extensions)
|
||||||
gluCheckExtension(const GLubyte *extension, const GLubyte *extensions)
|
|
||||||
{
|
{
|
||||||
const GLubyte *start;
|
const GLubyte *start;
|
||||||
GLubyte *where, *terminator;
|
GLubyte *where, *terminator;
|
||||||
|
|
||||||
/* Extension names should not have spaces. */
|
/* Extension names should not have spaces. */
|
||||||
where = (GLubyte *) strchr((const char*)extension, ' ');
|
where = (GLubyte *)strchr((const char *)extension, ' ');
|
||||||
if (where || *extension == '\0')
|
if (where || *extension == '\0') return 0;
|
||||||
|
/* It takes a bit of care to be fool-proof about parsing the
|
||||||
|
OpenGL extensions string. Don't be fooled by sub-strings,
|
||||||
|
etc. */
|
||||||
|
start = extensions;
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
where = (GLubyte *)strstr((const char *)start, (const char *)extension);
|
||||||
|
if (!where) break;
|
||||||
|
terminator = where + strlen((const char *)extension);
|
||||||
|
if (where == start || *(where - 1) == ' ')
|
||||||
|
if (*terminator == ' ' || *terminator == '\0') return 1;
|
||||||
|
start = terminator;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
/* It takes a bit of care to be fool-proof about parsing the
|
|
||||||
OpenGL extensions string. Don't be fooled by sub-strings,
|
|
||||||
etc. */
|
|
||||||
start = extensions;
|
|
||||||
for (;;) {
|
|
||||||
where = (GLubyte *) strstr((const char *) start, (const char*) extension);
|
|
||||||
if (!where)
|
|
||||||
break;
|
|
||||||
terminator = where + strlen((const char*) extension);
|
|
||||||
if (where == start || *(where - 1) == ' ')
|
|
||||||
if (*terminator == ' ' || *terminator == '\0')
|
|
||||||
return 1;
|
|
||||||
start = terminator;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// This is defined in the write common code:
|
// This is defined in the write common code:
|
||||||
extern int test_cl_image_write( cl_context context, cl_command_queue queue,
|
extern int test_cl_image_write(cl_context context, cl_command_queue queue,
|
||||||
GLenum target, cl_mem clImage, size_t width, size_t height, size_t depth,
|
GLenum target, cl_mem clImage, size_t width,
|
||||||
cl_image_format *outFormat, ExplicitType *outType, void **outSourceBuffer,
|
size_t height, size_t depth,
|
||||||
MTdata d, bool supports_half );
|
cl_image_format *outFormat,
|
||||||
|
ExplicitType *outType, void **outSourceBuffer,
|
||||||
|
MTdata d, bool supports_half);
|
||||||
|
|
||||||
extern int test_cl_image_read( cl_context context, cl_command_queue queue,
|
extern int test_cl_image_read(cl_context context, cl_command_queue queue,
|
||||||
GLenum gl_target, cl_mem image, size_t width, size_t height, size_t depth, size_t sampleNum,
|
GLenum gl_target, cl_mem image, size_t width,
|
||||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer );
|
size_t height, size_t depth, size_t sampleNum,
|
||||||
|
cl_image_format *outFormat, ExplicitType *outType,
|
||||||
|
void **outResultBuffer);
|
||||||
|
|
||||||
extern int supportsHalf(cl_context context, bool* supports_half);
|
extern int supportsHalf(cl_context context, bool *supports_half);
|
||||||
|
|
||||||
static int test_attach_renderbuffer_read_image( cl_context context, cl_command_queue queue, GLenum glTarget, GLuint glRenderbuffer,
|
static int test_attach_renderbuffer_read_image(
|
||||||
size_t imageWidth, size_t imageHeight, cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
cl_context context, cl_command_queue queue, GLenum glTarget,
|
||||||
|
GLuint glRenderbuffer, size_t imageWidth, size_t imageHeight,
|
||||||
|
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
// Create a CL image from the supplied GL renderbuffer
|
// Create a CL image from the supplied GL renderbuffer
|
||||||
cl_mem image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_READ_ONLY, glRenderbuffer, &error );
|
cl_mem image = (*clCreateFromGLRenderbuffer_ptr)(context, CL_MEM_READ_ONLY,
|
||||||
if( error != CL_SUCCESS )
|
glRenderbuffer, &error);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
{
|
{
|
||||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
print_error(error, "Unable to create CL image from GL renderbuffer");
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return test_cl_image_read( context, queue, glTarget, image, imageWidth,
|
return test_cl_image_read(context, queue, glTarget, image, imageWidth,
|
||||||
imageHeight, 1, 1, outFormat, outType, outResultBuffer );
|
imageHeight, 1, 1, outFormat, outType,
|
||||||
|
outResultBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_renderbuffer_read_image( cl_context context, cl_command_queue queue,
|
int test_renderbuffer_read_image(cl_context context, cl_command_queue queue,
|
||||||
GLsizei width, GLsizei height, GLenum attachment,
|
GLsizei width, GLsizei height,
|
||||||
GLenum format, GLenum internalFormat,
|
GLenum attachment, GLenum format,
|
||||||
GLenum glType, ExplicitType type, MTdata d )
|
GLenum internalFormat, GLenum glType,
|
||||||
|
ExplicitType type, MTdata d)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if( type == kHalf )
|
if (type == kHalf)
|
||||||
if( DetectFloatToHalfRoundingMode(queue) )
|
if (DetectFloatToHalfRoundingMode(queue)) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Create the GL renderbuffer
|
// Create the GL renderbuffer
|
||||||
glFramebufferWrapper glFramebuffer;
|
glFramebufferWrapper glFramebuffer;
|
||||||
glRenderbufferWrapper glRenderbuffer;
|
glRenderbufferWrapper glRenderbuffer;
|
||||||
void *tmp = CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true );
|
void *tmp = CreateGLRenderbuffer(
|
||||||
|
width, height, attachment, format, internalFormat, glType, type,
|
||||||
|
&glFramebuffer, &glRenderbuffer, &error, d, true);
|
||||||
BufferOwningPtr<char> inputBuffer(tmp);
|
BufferOwningPtr<char> inputBuffer(tmp);
|
||||||
if( error != 0 )
|
if (error != 0)
|
||||||
{
|
{
|
||||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
if ((format == GL_RGBA_INTEGER_EXT)
|
||||||
|
&& (!CheckGLIntegerExtensionSupport()))
|
||||||
{
|
{
|
||||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. "
|
||||||
|
"Skipping test.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -114,14 +123,18 @@ int test_renderbuffer_read_image( cl_context context, cl_command_queue queue,
|
|||||||
cl_image_format clFormat;
|
cl_image_format clFormat;
|
||||||
ExplicitType actualType;
|
ExplicitType actualType;
|
||||||
char *outBuffer;
|
char *outBuffer;
|
||||||
error = test_attach_renderbuffer_read_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &actualType, (void **)&outBuffer );
|
error = test_attach_renderbuffer_read_image(
|
||||||
if( error != 0 )
|
context, queue, attachment, glRenderbuffer, width, height, &clFormat,
|
||||||
return error;
|
&actualType, (void **)&outBuffer);
|
||||||
|
if (error != 0) return error;
|
||||||
BufferOwningPtr<char> actualResults(outBuffer);
|
BufferOwningPtr<char> actualResults(outBuffer);
|
||||||
|
|
||||||
log_info( "- Read [%4d x %4d] : GL renderbuffer : %s : %s : %s => CL Image : %s : %s \n", width, height,
|
log_info("- Read [%4d x %4d] : GL renderbuffer : %s : %s : %s => CL Image "
|
||||||
GetGLFormatName( format ), GetGLFormatName( internalFormat ), GetGLTypeName( glType),
|
": %s : %s \n",
|
||||||
GetChannelOrderName( clFormat.image_channel_order ), GetChannelTypeName( clFormat.image_channel_data_type ));
|
width, height, GetGLFormatName(format),
|
||||||
|
GetGLFormatName(internalFormat), GetGLTypeName(glType),
|
||||||
|
GetChannelOrderName(clFormat.image_channel_order),
|
||||||
|
GetChannelTypeName(clFormat.image_channel_data_type));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start read GL data -- \n");
|
log_info("- start read GL data -- \n");
|
||||||
@@ -129,63 +142,76 @@ int test_renderbuffer_read_image( cl_context context, cl_command_queue queue,
|
|||||||
log_info("- end read GL data -- \n");
|
log_info("- end read GL data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We have to convert our input buffer to the returned type, so we can validate.
|
// We have to convert our input buffer to the returned type, so we can
|
||||||
BufferOwningPtr<char> convertedInput(convert_to_expected( inputBuffer, width * height, type, actualType, get_channel_order_channel_count(clFormat.image_channel_order) ));
|
// validate.
|
||||||
|
BufferOwningPtr<char> convertedInput(convert_to_expected(
|
||||||
|
inputBuffer, width * height, type, actualType,
|
||||||
|
get_channel_order_channel_count(clFormat.image_channel_order)));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start input data -- \n");
|
log_info("- start input data -- \n");
|
||||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, convertedInput);
|
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height,
|
||||||
|
convertedInput);
|
||||||
log_info("- end input data -- \n");
|
log_info("- end input data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start converted data -- \n");
|
log_info("- start converted data -- \n");
|
||||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, actualResults);
|
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height,
|
||||||
|
actualResults);
|
||||||
log_info("- end converted data -- \n");
|
log_info("- end converted data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Now we validate
|
// Now we validate
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
if(convertedInput) {
|
if (convertedInput)
|
||||||
if( actualType == kFloat )
|
{
|
||||||
valid = validate_float_results( convertedInput, actualResults, width, height, 1, get_channel_order_channel_count(clFormat.image_channel_order) );
|
if (actualType == kFloat)
|
||||||
|
valid = validate_float_results(
|
||||||
|
convertedInput, actualResults, width, height, 1,
|
||||||
|
get_channel_order_channel_count(clFormat.image_channel_order));
|
||||||
else
|
else
|
||||||
valid = validate_integer_results( convertedInput, actualResults, width, height, 1, get_explicit_type_size( actualType ) );
|
valid = validate_integer_results(
|
||||||
|
convertedInput, actualResults, width, height, 1,
|
||||||
|
get_explicit_type_size(actualType));
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_renderbuffer_read( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
int test_renderbuffer_read(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
GLenum internal;
|
GLenum internal;
|
||||||
GLenum format;
|
GLenum format;
|
||||||
GLenum datatype;
|
GLenum datatype;
|
||||||
ExplicitType type;
|
ExplicitType type;
|
||||||
|
|
||||||
} formats[] = {
|
} formats[] = {
|
||||||
{ GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
{ GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
||||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
||||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||||
|
|
||||||
// Renderbuffers with integer formats do not seem to work reliably across
|
// Renderbuffers with integer formats do not seem to work reliably across
|
||||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
// platforms/implementations. Disabling this in version 1.0 of CL
|
||||||
|
// conformance tests.
|
||||||
|
|
||||||
#ifdef TEST_INTEGER_FORMATS
|
#ifdef TEST_INTEGER_FORMATS
|
||||||
|
|
||||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||||
#endif
|
#endif
|
||||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t fmtIdx, attIdx;
|
size_t fmtIdx, attIdx;
|
||||||
@@ -195,66 +221,70 @@ int test_renderbuffer_read( cl_device_id device, cl_context context, cl_command_
|
|||||||
#else
|
#else
|
||||||
size_t iter = 6;
|
size_t iter = 6;
|
||||||
#endif
|
#endif
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Check if images are supported
|
// Check if images are supported
|
||||||
if (checkForImageSupport(device)) {
|
if (checkForImageSupport(device))
|
||||||
log_info("Device does not support images. Skipping test.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !gluCheckExtension( (const GLubyte *)"GL_EXT_framebuffer_object", glGetString( GL_EXTENSIONS ) ) )
|
|
||||||
{
|
{
|
||||||
log_info( "Renderbuffers are not supported by this OpenGL implementation; skipping test\n" );
|
log_info("Device does not support images. Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gluCheckExtension((const GLubyte *)"GL_EXT_framebuffer_object",
|
||||||
|
glGetString(GL_EXTENSIONS)))
|
||||||
|
{
|
||||||
|
log_info("Renderbuffers are not supported by this OpenGL "
|
||||||
|
"implementation; skipping test\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through a set of GL formats, testing a set of sizes against each one
|
// Loop through a set of GL formats, testing a set of sizes against each one
|
||||||
for( fmtIdx = 0; fmtIdx < sizeof( formats ) / sizeof( formats[ 0 ] ); fmtIdx++ )
|
for (fmtIdx = 0; fmtIdx < sizeof(formats) / sizeof(formats[0]); fmtIdx++)
|
||||||
{
|
{
|
||||||
for( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
for (attIdx = 0; attIdx < sizeof(attachments) / sizeof(attachments[0]);
|
||||||
|
attIdx++)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
log_info( "Testing renderbuffer read for %s : %s : %s : %s\n",
|
log_info("Testing renderbuffer read for %s : %s : %s : %s\n",
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
for( i = 0; i < iter; i++ )
|
for (i = 0; i < iter; i++)
|
||||||
{
|
{
|
||||||
GLsizei width = random_in_range( 16, 512, seed );
|
GLsizei width = random_in_range(16, 512, seed);
|
||||||
GLsizei height = random_in_range( 16, 512, seed );
|
GLsizei height = random_in_range(16, 512, seed);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
width = height = 4;
|
width = height = 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( test_renderbuffer_read_image( context, queue, width, height,
|
if (test_renderbuffer_read_image(
|
||||||
attachments[ attIdx ],
|
context, queue, width, height, attachments[attIdx],
|
||||||
formats[ fmtIdx ].format,
|
formats[fmtIdx].format, formats[fmtIdx].internal,
|
||||||
formats[ fmtIdx ].internal,
|
formats[fmtIdx].datatype, formats[fmtIdx].type, seed))
|
||||||
formats[ fmtIdx ].datatype,
|
|
||||||
formats[ fmtIdx ].type, seed ) )
|
|
||||||
|
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Renderbuffer read test failed for %s : %s : %s : %s\n\n",
|
log_error("ERROR: Renderbuffer read test failed for %s : "
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
"%s : %s : %s\n\n",
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
error++;
|
error++;
|
||||||
break; // Skip other sizes for this combination
|
break; // Skip other sizes for this combination
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( i == iter )
|
if (i == iter)
|
||||||
{
|
{
|
||||||
log_info( "passed: Renderbuffer read test passed for %s : %s : %s : %s\n\n",
|
log_info("passed: Renderbuffer read test passed for %s : %s : "
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
"%s : %s\n\n",
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -265,43 +295,52 @@ int test_renderbuffer_read( cl_device_id device, cl_context context, cl_command_
|
|||||||
|
|
||||||
#pragma mark -------------------- Write tests -------------------------
|
#pragma mark -------------------- Write tests -------------------------
|
||||||
|
|
||||||
int test_attach_renderbuffer_write_to_image( cl_context context, cl_command_queue queue, GLenum glTarget, GLuint glRenderbuffer,
|
int test_attach_renderbuffer_write_to_image(
|
||||||
size_t imageWidth, size_t imageHeight, cl_image_format *outFormat, ExplicitType *outType, MTdata d, void **outSourceBuffer, bool supports_half )
|
cl_context context, cl_command_queue queue, GLenum glTarget,
|
||||||
|
GLuint glRenderbuffer, size_t imageWidth, size_t imageHeight,
|
||||||
|
cl_image_format *outFormat, ExplicitType *outType, MTdata d,
|
||||||
|
void **outSourceBuffer, bool supports_half)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
// Create a CL image from the supplied GL renderbuffer
|
// Create a CL image from the supplied GL renderbuffer
|
||||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_WRITE_ONLY, glRenderbuffer, &error );
|
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)(
|
||||||
if( error != CL_SUCCESS )
|
context, CL_MEM_WRITE_ONLY, glRenderbuffer, &error);
|
||||||
|
if (error != CL_SUCCESS)
|
||||||
{
|
{
|
||||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
print_error(error, "Unable to create CL image from GL renderbuffer");
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
return test_cl_image_write( context, queue, glTarget, image, imageWidth,
|
return test_cl_image_write(context, queue, glTarget, image, imageWidth,
|
||||||
imageHeight, 1, outFormat, outType, outSourceBuffer, d, supports_half );
|
imageHeight, 1, outFormat, outType,
|
||||||
|
outSourceBuffer, d, supports_half);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_renderbuffer_image_write( cl_context context, cl_command_queue queue,
|
int test_renderbuffer_image_write(cl_context context, cl_command_queue queue,
|
||||||
GLsizei width, GLsizei height, GLenum attachment,
|
GLsizei width, GLsizei height,
|
||||||
GLenum format, GLenum internalFormat,
|
GLenum attachment, GLenum format,
|
||||||
GLenum glType, ExplicitType type, MTdata d )
|
GLenum internalFormat, GLenum glType,
|
||||||
|
ExplicitType type, MTdata d)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if( type == kHalf )
|
if (type == kHalf)
|
||||||
if( DetectFloatToHalfRoundingMode(queue) )
|
if (DetectFloatToHalfRoundingMode(queue)) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Create the GL renderbuffer
|
// Create the GL renderbuffer
|
||||||
glFramebufferWrapper glFramebuffer;
|
glFramebufferWrapper glFramebuffer;
|
||||||
glRenderbufferWrapper glRenderbuffer;
|
glRenderbufferWrapper glRenderbuffer;
|
||||||
CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, false );
|
CreateGLRenderbuffer(width, height, attachment, format, internalFormat,
|
||||||
if( error != 0 )
|
glType, type, &glFramebuffer, &glRenderbuffer, &error,
|
||||||
|
d, false);
|
||||||
|
if (error != 0)
|
||||||
{
|
{
|
||||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
if ((format == GL_RGBA_INTEGER_EXT)
|
||||||
|
&& (!CheckGLIntegerExtensionSupport()))
|
||||||
{
|
{
|
||||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. "
|
||||||
|
"Skipping test.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -318,27 +357,34 @@ int test_renderbuffer_image_write( cl_context context, cl_command_queue queue,
|
|||||||
|
|
||||||
bool supports_half = false;
|
bool supports_half = false;
|
||||||
error = supportsHalf(context, &supports_half);
|
error = supportsHalf(context, &supports_half);
|
||||||
if( error != 0 )
|
if (error != 0) return error;
|
||||||
return error;
|
|
||||||
|
|
||||||
error = test_attach_renderbuffer_write_to_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &sourceType, d, (void **)&outSourceBuffer, supports_half );
|
error = test_attach_renderbuffer_write_to_image(
|
||||||
if( error != 0 || ((sourceType == kHalf ) && !supports_half))
|
context, queue, attachment, glRenderbuffer, width, height, &clFormat,
|
||||||
return error;
|
&sourceType, d, (void **)&outSourceBuffer, supports_half);
|
||||||
|
if (error != 0 || ((sourceType == kHalf) && !supports_half)) return error;
|
||||||
|
|
||||||
// If actual source type was half, convert to float for validation.
|
// If actual source type was half, convert to float for validation.
|
||||||
if( sourceType == kHalf )
|
if (sourceType == kHalf)
|
||||||
validationType = kFloat;
|
validationType = kFloat;
|
||||||
else
|
else
|
||||||
validationType = sourceType;
|
validationType = sourceType;
|
||||||
|
|
||||||
BufferOwningPtr<char> validationSource( convert_to_expected( outSourceBuffer, width * height, sourceType, validationType, get_channel_order_channel_count(clFormat.image_channel_order) ) );
|
BufferOwningPtr<char> validationSource(convert_to_expected(
|
||||||
|
outSourceBuffer, width * height, sourceType, validationType,
|
||||||
|
get_channel_order_channel_count(clFormat.image_channel_order)));
|
||||||
|
|
||||||
log_info( "- Write [%4d x %4d] : GL Renderbuffer : %s : %s : %s => CL Image : %s : %s \n", width, height,
|
log_info("- Write [%4d x %4d] : GL Renderbuffer : %s : %s : %s => CL Image "
|
||||||
GetGLFormatName( format ), GetGLFormatName( internalFormat ), GetGLTypeName( glType),
|
": %s : %s \n",
|
||||||
GetChannelOrderName( clFormat.image_channel_order ), GetChannelTypeName( clFormat.image_channel_data_type ));
|
width, height, GetGLFormatName(format),
|
||||||
|
GetGLFormatName(internalFormat), GetGLTypeName(glType),
|
||||||
|
GetChannelOrderName(clFormat.image_channel_order),
|
||||||
|
GetChannelTypeName(clFormat.image_channel_data_type));
|
||||||
|
|
||||||
// Now read the results from the GL renderbuffer
|
// Now read the results from the GL renderbuffer
|
||||||
BufferOwningPtr<char> resultData( ReadGLRenderbuffer( glFramebuffer, glRenderbuffer, attachment, format, internalFormat, glType, type, width, height ) );
|
BufferOwningPtr<char> resultData(
|
||||||
|
ReadGLRenderbuffer(glFramebuffer, glRenderbuffer, attachment, format,
|
||||||
|
internalFormat, glType, type, width, height));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start result data -- \n");
|
log_info("- start result data -- \n");
|
||||||
@@ -346,63 +392,76 @@ int test_renderbuffer_image_write( cl_context context, cl_command_queue queue,
|
|||||||
log_info("- end result data -- \n");
|
log_info("- end result data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// We have to convert our input buffer to the returned type, so we can validate.
|
// We have to convert our input buffer to the returned type, so we can
|
||||||
BufferOwningPtr<char> convertedData( convert_to_expected( resultData, width * height, type, validationType, get_channel_order_channel_count(clFormat.image_channel_order) ) );
|
// validate.
|
||||||
|
BufferOwningPtr<char> convertedData(convert_to_expected(
|
||||||
|
resultData, width * height, type, validationType,
|
||||||
|
get_channel_order_channel_count(clFormat.image_channel_order)));
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start input data -- \n");
|
log_info("- start input data -- \n");
|
||||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, validationSource);
|
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height,
|
||||||
|
validationSource);
|
||||||
log_info("- end input data -- \n");
|
log_info("- end input data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
log_info("- start converted data -- \n");
|
log_info("- start converted data -- \n");
|
||||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, convertedData);
|
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height,
|
||||||
|
convertedData);
|
||||||
log_info("- end converted data -- \n");
|
log_info("- end converted data -- \n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Now we validate
|
// Now we validate
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
if(convertedData) {
|
if (convertedData)
|
||||||
if( sourceType == kFloat || sourceType == kHalf )
|
{
|
||||||
valid = validate_float_results( validationSource, convertedData, width, height, 1, get_channel_order_channel_count(clFormat.image_channel_order) );
|
if (sourceType == kFloat || sourceType == kHalf)
|
||||||
|
valid = validate_float_results(
|
||||||
|
validationSource, convertedData, width, height, 1,
|
||||||
|
get_channel_order_channel_count(clFormat.image_channel_order));
|
||||||
else
|
else
|
||||||
valid = validate_integer_results( validationSource, convertedData, width, height, 1, get_explicit_type_size( type ) );
|
valid = validate_integer_results(validationSource, convertedData,
|
||||||
|
width, height, 1,
|
||||||
|
get_explicit_type_size(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_renderbuffer_write( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
int test_renderbuffer_write(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
GLenum internal;
|
GLenum internal;
|
||||||
GLenum format;
|
GLenum format;
|
||||||
GLenum datatype;
|
GLenum datatype;
|
||||||
ExplicitType type;
|
ExplicitType type;
|
||||||
|
|
||||||
} formats[] = {
|
} formats[] = {
|
||||||
{ GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
{ GL_RGBA, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
||||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, kUChar },
|
||||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||||
|
|
||||||
// Renderbuffers with integer formats do not seem to work reliably across
|
// Renderbuffers with integer formats do not seem to work reliably across
|
||||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
// platforms/implementations. Disabling this in version 1.0 of CL
|
||||||
|
// conformance tests.
|
||||||
|
|
||||||
#ifdef TEST_INTEGER_FORMATS
|
#ifdef TEST_INTEGER_FORMATS
|
||||||
|
|
||||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||||
#endif
|
#endif
|
||||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t fmtIdx, attIdx;
|
size_t fmtIdx, attIdx;
|
||||||
@@ -411,64 +470,68 @@ int test_renderbuffer_write( cl_device_id device, cl_context context, cl_command
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
iter = 1;
|
iter = 1;
|
||||||
#endif
|
#endif
|
||||||
RandomSeed seed( gRandomSeed );
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Check if images are supported
|
// Check if images are supported
|
||||||
if (checkForImageSupport(device)) {
|
if (checkForImageSupport(device))
|
||||||
log_info("Device does not support images. Skipping test.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !gluCheckExtension( (const GLubyte *)"GL_EXT_framebuffer_object", glGetString( GL_EXTENSIONS ) ) )
|
|
||||||
{
|
{
|
||||||
log_info( "Renderbuffers are not supported by this OpenGL implementation; skipping test\n" );
|
log_info("Device does not support images. Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gluCheckExtension((const GLubyte *)"GL_EXT_framebuffer_object",
|
||||||
|
glGetString(GL_EXTENSIONS)))
|
||||||
|
{
|
||||||
|
log_info("Renderbuffers are not supported by this OpenGL "
|
||||||
|
"implementation; skipping test\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through a set of GL formats, testing a set of sizes against each one
|
// Loop through a set of GL formats, testing a set of sizes against each one
|
||||||
for( fmtIdx = 0; fmtIdx < sizeof( formats ) / sizeof( formats[ 0 ] ); fmtIdx++ )
|
for (fmtIdx = 0; fmtIdx < sizeof(formats) / sizeof(formats[0]); fmtIdx++)
|
||||||
{
|
{
|
||||||
for( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
for (attIdx = 0; attIdx < sizeof(attachments) / sizeof(attachments[0]);
|
||||||
|
attIdx++)
|
||||||
{
|
{
|
||||||
log_info( "Testing Renderbuffer write test for %s : %s : %s : %s\n",
|
log_info("Testing Renderbuffer write test for %s : %s : %s : %s\n",
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for( i = 0; i < iter; i++ )
|
for (i = 0; i < iter; i++)
|
||||||
{
|
{
|
||||||
GLsizei width = random_in_range( 16, 512, seed );
|
GLsizei width = random_in_range(16, 512, seed);
|
||||||
GLsizei height = random_in_range( 16, 512, seed );
|
GLsizei height = random_in_range(16, 512, seed);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
width = height = 4;
|
width = height = 4;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if( test_renderbuffer_image_write( context, queue, width, height,
|
if (test_renderbuffer_image_write(
|
||||||
attachments[ attIdx ],
|
context, queue, width, height, attachments[attIdx],
|
||||||
formats[ fmtIdx ].format,
|
formats[fmtIdx].format, formats[fmtIdx].internal,
|
||||||
formats[ fmtIdx ].internal,
|
formats[fmtIdx].datatype, formats[fmtIdx].type, seed))
|
||||||
formats[ fmtIdx ].datatype,
|
|
||||||
formats[ fmtIdx ].type, seed ) )
|
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Renderbuffer write test failed for %s : %s : %s : %s\n\n",
|
log_error("ERROR: Renderbuffer write test failed for %s : "
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
"%s : %s : %s\n\n",
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
error++;
|
error++;
|
||||||
break; // Skip other sizes for this combination
|
break; // Skip other sizes for this combination
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( i == iter )
|
if (i == iter)
|
||||||
{
|
{
|
||||||
log_info( "passed: Renderbuffer write test passed for %s : %s : %s : %s\n\n",
|
log_info("passed: Renderbuffer write test passed for %s : %s : "
|
||||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
"%s : %s\n\n",
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLAttachmentName(attachments[attIdx]),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
//
|
//
|
||||||
// Copyright (c) 2017 The Khronos Group Inc.
|
// Copyright (c) 2017 The Khronos Group Inc.
|
||||||
//
|
//
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
// you may not use this file except in compliance with the License.
|
// you may not use this file except in compliance with the License.
|
||||||
// You may obtain a copy of the License at
|
// You may obtain a copy of the License at
|
||||||
@@ -14,118 +14,125 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
#include "testBase.h"
|
#include "testBase.h"
|
||||||
#if defined( __APPLE__ )
|
#if defined(__APPLE__)
|
||||||
#include <OpenGL/glu.h>
|
#include <OpenGL/glu.h>
|
||||||
#else
|
#else
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
#include <CL/cl_gl.h>
|
#include <CL/cl_gl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int test_renderbuffer_object_info( cl_context context, cl_command_queue queue,
|
static int test_renderbuffer_object_info(cl_context context,
|
||||||
GLsizei width, GLsizei height, GLenum attachment,
|
cl_command_queue queue, GLsizei width,
|
||||||
GLenum format, GLenum internalFormat,
|
GLsizei height, GLenum attachment,
|
||||||
GLenum glType, ExplicitType type, MTdata d )
|
GLenum format, GLenum internalFormat,
|
||||||
|
GLenum glType, ExplicitType type,
|
||||||
|
MTdata d)
|
||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if( type == kHalf )
|
if (type == kHalf)
|
||||||
if( DetectFloatToHalfRoundingMode(queue) )
|
if (DetectFloatToHalfRoundingMode(queue)) return 1;
|
||||||
return 1;
|
|
||||||
|
|
||||||
// Create the GL render buffer
|
// Create the GL render buffer
|
||||||
glFramebufferWrapper glFramebuffer;
|
glFramebufferWrapper glFramebuffer;
|
||||||
glRenderbufferWrapper glRenderbuffer;
|
glRenderbufferWrapper glRenderbuffer;
|
||||||
BufferOwningPtr<char> inputBuffer(CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true ));
|
BufferOwningPtr<char> inputBuffer(CreateGLRenderbuffer(
|
||||||
if( error != 0 )
|
width, height, attachment, format, internalFormat, glType, type,
|
||||||
return error;
|
&glFramebuffer, &glRenderbuffer, &error, d, true));
|
||||||
|
if (error != 0) return error;
|
||||||
|
|
||||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)(context, CL_MEM_READ_ONLY, glRenderbuffer, &error);
|
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)(
|
||||||
|
context, CL_MEM_READ_ONLY, glRenderbuffer, &error);
|
||||||
test_error(error, "clCreateFromGLRenderbuffer failed");
|
test_error(error, "clCreateFromGLRenderbuffer failed");
|
||||||
|
|
||||||
log_info( "- Given a GL format of %s, input type was %s, size was %d x %d\n",
|
log_info("- Given a GL format of %s, input type was %s, size was %d x %d\n",
|
||||||
GetGLFormatName( internalFormat ),
|
GetGLFormatName(internalFormat), get_explicit_type_name(type),
|
||||||
get_explicit_type_name( type ), (int)width, (int)height );
|
(int)width, (int)height);
|
||||||
|
|
||||||
// Verify the expected information here.
|
// Verify the expected information here.
|
||||||
return CheckGLObjectInfo(image, CL_GL_OBJECT_RENDERBUFFER, (GLuint)glRenderbuffer, internalFormat, 0);
|
return CheckGLObjectInfo(image, CL_GL_OBJECT_RENDERBUFFER,
|
||||||
|
(GLuint)glRenderbuffer, internalFormat, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int test_renderbuffer_getinfo( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
int test_renderbuffer_getinfo(cl_device_id device, cl_context context,
|
||||||
|
cl_command_queue queue, int numElements)
|
||||||
{
|
{
|
||||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||||
|
|
||||||
struct {
|
struct
|
||||||
|
{
|
||||||
GLenum internal;
|
GLenum internal;
|
||||||
GLenum format;
|
GLenum format;
|
||||||
GLenum datatype;
|
GLenum datatype;
|
||||||
ExplicitType type;
|
ExplicitType type;
|
||||||
|
|
||||||
} formats[] = {
|
} formats[] = { { GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf } };
|
||||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
|
||||||
};
|
|
||||||
|
|
||||||
size_t fmtIdx, tgtIdx;
|
size_t fmtIdx, tgtIdx;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
size_t iter = 6;
|
size_t iter = 6;
|
||||||
RandomSeed seed(gRandomSeed);
|
RandomSeed seed(gRandomSeed);
|
||||||
|
|
||||||
// Check if images are supported
|
// Check if images are supported
|
||||||
if (checkForImageSupport(device)) {
|
if (checkForImageSupport(device))
|
||||||
log_info("Device does not support images. Skipping test.\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !gluCheckExtension( (const GLubyte *)"GL_EXT_framebuffer_object", glGetString( GL_EXTENSIONS ) ) )
|
|
||||||
{
|
{
|
||||||
log_info( "Renderbuffers are not supported by this OpenGL implementation; skipping test\n" );
|
log_info("Device does not support images. Skipping test.\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!gluCheckExtension((const GLubyte *)"GL_EXT_framebuffer_object",
|
||||||
|
glGetString(GL_EXTENSIONS)))
|
||||||
|
{
|
||||||
|
log_info("Renderbuffers are not supported by this OpenGL "
|
||||||
|
"implementation; skipping test\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop through a set of GL formats, testing a set of sizes against each one
|
// Loop through a set of GL formats, testing a set of sizes against each one
|
||||||
for( fmtIdx = 0; fmtIdx < sizeof( formats ) / sizeof( formats[ 0 ] ); fmtIdx++ )
|
for (fmtIdx = 0; fmtIdx < sizeof(formats) / sizeof(formats[0]); fmtIdx++)
|
||||||
{
|
{
|
||||||
for( tgtIdx = 0; tgtIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); tgtIdx++ )
|
for (tgtIdx = 0; tgtIdx < sizeof(attachments) / sizeof(attachments[0]);
|
||||||
|
tgtIdx++)
|
||||||
{
|
{
|
||||||
log_info( "Testing Renderbuffer object info for %s : %s : %s\n",
|
log_info("Testing Renderbuffer object info for %s : %s : %s\n",
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
GetGLBaseFormatName(formats[fmtIdx].format),
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for( i = 0; i < iter; i++ )
|
for (i = 0; i < iter; i++)
|
||||||
{
|
{
|
||||||
GLsizei width = random_in_range( 16, 512, seed );
|
GLsizei width = random_in_range(16, 512, seed);
|
||||||
GLsizei height = random_in_range( 16, 512, seed );
|
GLsizei height = random_in_range(16, 512, seed);
|
||||||
|
|
||||||
if( test_renderbuffer_object_info( context, queue, (int)width, (int)height,
|
if (test_renderbuffer_object_info(
|
||||||
attachments[ tgtIdx ],
|
context, queue, (int)width, (int)height,
|
||||||
formats[ fmtIdx ].format,
|
attachments[tgtIdx], formats[fmtIdx].format,
|
||||||
formats[ fmtIdx ].internal,
|
formats[fmtIdx].internal, formats[fmtIdx].datatype,
|
||||||
formats[ fmtIdx ].datatype,
|
formats[fmtIdx].type, seed))
|
||||||
formats[ fmtIdx ].type, seed ) )
|
|
||||||
{
|
{
|
||||||
log_error( "ERROR: Renderbuffer write test failed for GL format %s : %s\n\n",
|
log_error("ERROR: Renderbuffer write test failed for GL "
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
"format %s : %s\n\n",
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
|
|
||||||
error++;
|
error++;
|
||||||
break; // Skip other sizes for this combination
|
break; // Skip other sizes for this combination
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( i == iter )
|
if (i == iter)
|
||||||
{
|
{
|
||||||
log_info( "passed: Renderbuffer write test passed for GL format %s : %s\n\n",
|
log_info("passed: Renderbuffer write test passed for GL format "
|
||||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
"%s : %s\n\n",
|
||||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
GetGLFormatName(formats[fmtIdx].internal),
|
||||||
|
GetGLTypeName(formats[fmtIdx].datatype));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user