mirror of
https://github.com/KhronosGroup/OpenCL-CTS.git
synced 2026-03-22 15:19:02 +00:00
Synchronise with Khronos-private Gitlab branch
The maintenance of the conformance tests is moving to Github. This commit contains all the changes that have been done in Gitlab since the first public release of the conformance tests. Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,28 +1,28 @@
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_gl
|
||||
: helpers.cpp
|
||||
main.cpp
|
||||
test_buffers.cpp
|
||||
test_images_2D.cpp
|
||||
test_images_2D_info.cpp
|
||||
test_images_3D.cpp
|
||||
test_images_3D_info.cpp
|
||||
test_renderbuffer.cpp
|
||||
test_renderbuffer_info.cpp
|
||||
: <target-os>darwin:<source>setup_osx.cpp
|
||||
<target-os>linux:<source>setup_x11.cpp
|
||||
<target-os>windows:<source>setup_win32.cpp
|
||||
<library>../..//glut
|
||||
<library>../..//glew
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_gl
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/gl
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/gl
|
||||
;
|
||||
project
|
||||
: requirements
|
||||
# <toolset>gcc:<cflags>-xc++
|
||||
# <toolset>msvc:<cflags>"/TP"
|
||||
;
|
||||
|
||||
exe test_gl
|
||||
: helpers.cpp
|
||||
main.cpp
|
||||
test_buffers.cpp
|
||||
test_images_2D.cpp
|
||||
test_images_2D_info.cpp
|
||||
test_images_3D.cpp
|
||||
test_images_3D_info.cpp
|
||||
test_renderbuffer.cpp
|
||||
test_renderbuffer_info.cpp
|
||||
: <target-os>darwin:<source>setup_osx.cpp
|
||||
<target-os>linux:<source>setup_x11.cpp
|
||||
<target-os>windows:<source>setup_win32.cpp
|
||||
<library>../..//glut
|
||||
<library>../..//glew
|
||||
;
|
||||
|
||||
install dist
|
||||
: test_gl
|
||||
: <variant>debug:<location>$(DIST)/debug/tests/test_conformance/gl
|
||||
<variant>release:<location>$(DIST)/release/tests/test_conformance/gl
|
||||
;
|
||||
|
||||
@@ -1,60 +1,60 @@
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
helpers.cpp \
|
||||
test_buffers.cpp \
|
||||
test_fence_sync.cpp \
|
||||
test_images_1D.cpp \
|
||||
test_images_1Darray.cpp \
|
||||
test_images_2Darray.cpp \
|
||||
test_images_2D.cpp \
|
||||
test_images_3D.cpp \
|
||||
test_images_getinfo_common.cpp \
|
||||
test_images_read_common.cpp \
|
||||
test_images_write_common.cpp \
|
||||
test_renderbuffer.cpp \
|
||||
test_renderbuffer_info.cpp \
|
||||
../images/image_helpers.cpp \
|
||||
../../test_common/gl/helpers.cpp \
|
||||
../../test_common/gl/setup_osx.cpp \
|
||||
../../test_common/harness/conversions.c \
|
||||
../../test_common/harness/errorHelpers.c \
|
||||
../../test_common/harness/genericThread.cpp \
|
||||
../../test_common/harness/imageHelpers.c \
|
||||
../../test_common/harness/kernelHelpers.c \
|
||||
../../test_common/harness/mt19937.c \
|
||||
../../test_common/harness/testHarness.c \
|
||||
../../test_common/harness/threadTesting.c
|
||||
|
||||
DEFINES =
|
||||
|
||||
SOURCES = $(abspath $(SRCS))
|
||||
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
|
||||
LIBPATH += -L.
|
||||
FRAMEWORK = $(SOURCES)
|
||||
HEADERS =
|
||||
TARGET = test_gl
|
||||
INCLUDE =
|
||||
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32
|
||||
CC = c++
|
||||
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
|
||||
|
||||
OBJECTS := ${SOURCES:.c=.o}
|
||||
OBJECTS := ${OBJECTS:.cpp=.o}
|
||||
|
||||
TARGETOBJECT =
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.DEFAULT:
|
||||
@echo The target \"$@\" does not exist in Makefile.
|
||||
ifdef BUILD_WITH_ATF
|
||||
ATF = -framework ATF
|
||||
USE_ATF = -DUSE_ATF
|
||||
endif
|
||||
|
||||
SRCS = main.cpp \
|
||||
helpers.cpp \
|
||||
test_buffers.cpp \
|
||||
test_fence_sync.cpp \
|
||||
test_images_1D.cpp \
|
||||
test_images_1Darray.cpp \
|
||||
test_images_2Darray.cpp \
|
||||
test_images_2D.cpp \
|
||||
test_images_3D.cpp \
|
||||
test_images_getinfo_common.cpp \
|
||||
test_images_read_common.cpp \
|
||||
test_images_write_common.cpp \
|
||||
test_renderbuffer.cpp \
|
||||
test_renderbuffer_info.cpp \
|
||||
../images/image_helpers.cpp \
|
||||
../../test_common/gl/helpers.cpp \
|
||||
../../test_common/gl/setup_osx.cpp \
|
||||
../../test_common/harness/conversions.c \
|
||||
../../test_common/harness/errorHelpers.c \
|
||||
../../test_common/harness/genericThread.cpp \
|
||||
../../test_common/harness/imageHelpers.c \
|
||||
../../test_common/harness/kernelHelpers.c \
|
||||
../../test_common/harness/mt19937.c \
|
||||
../../test_common/harness/testHarness.c \
|
||||
../../test_common/harness/threadTesting.c
|
||||
|
||||
DEFINES =
|
||||
|
||||
SOURCES = $(abspath $(SRCS))
|
||||
LIBPATH += -L/System/Library/Frameworks/OpenCL.framework/Libraries
|
||||
LIBPATH += -L.
|
||||
FRAMEWORK = $(SOURCES)
|
||||
HEADERS =
|
||||
TARGET = test_gl
|
||||
INCLUDE =
|
||||
COMPILERFLAGS = -c -Wall -g -Wshorten-64-to-32
|
||||
CC = c++
|
||||
CFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
CXXFLAGS = $(COMPILERFLAGS) ${RC_CFLAGS} ${USE_ATF} $(DEFINES:%=-D%) $(INCLUDE)
|
||||
LIBRARIES = -framework OpenCL -framework OpenGL -framework GLUT -framework AppKit ${ATF}
|
||||
|
||||
OBJECTS := ${SOURCES:.c=.o}
|
||||
OBJECTS := ${OBJECTS:.cpp=.o}
|
||||
|
||||
TARGETOBJECT =
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJECTS)
|
||||
$(CC) $(RC_CFLAGS) $(OBJECTS) -o $@ $(LIBPATH) $(LIBRARIES)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
||||
|
||||
.DEFAULT:
|
||||
@echo The target \"$@\" does not exist in Makefile.
|
||||
|
||||
@@ -1,66 +1,66 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#include "testBase.h"
|
||||
|
||||
typedef struct {
|
||||
size_t width;
|
||||
size_t height;
|
||||
size_t depth;
|
||||
} sizevec_t;
|
||||
|
||||
struct format {
|
||||
GLenum internal;
|
||||
GLenum formattype;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
};
|
||||
|
||||
// These are the typically tested formats.
|
||||
|
||||
static struct format common_formats[] = {
|
||||
#ifdef __APPLE__
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 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 },
|
||||
#endif
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
int test_images_write_common(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, sizevec_t* sizes, size_t nsizes );
|
||||
|
||||
int test_images_read_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes );
|
||||
|
||||
int test_images_get_info_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes );
|
||||
|
||||
#endif // __COMMON_H__
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#include "testBase.h"
|
||||
|
||||
typedef struct {
|
||||
size_t width;
|
||||
size_t height;
|
||||
size_t depth;
|
||||
} sizevec_t;
|
||||
|
||||
struct format {
|
||||
GLenum internal;
|
||||
GLenum formattype;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
};
|
||||
|
||||
// These are the typically tested formats.
|
||||
|
||||
static struct format common_formats[] = {
|
||||
#ifdef __APPLE__
|
||||
{ GL_RGBA8, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 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 },
|
||||
#endif
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
int test_images_write_common(cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, sizevec_t* sizes, size_t nsizes );
|
||||
|
||||
int test_images_read_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes );
|
||||
|
||||
int test_images_get_info_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes );
|
||||
|
||||
#endif // __COMMON_H__
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,386 +1,386 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#include "procs.h"
|
||||
#include "../../test_common/gl/setup.h"
|
||||
#include "../../test_common/harness/testHarness.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static cl_context sCurrentContext = NULL;
|
||||
|
||||
|
||||
#define TEST_FN_REDIRECT( fn ) redirect_##fn
|
||||
#define TEST_FN_REDIRECTOR( fn ) \
|
||||
int redirect_##fn(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) \
|
||||
{ \
|
||||
int error; \
|
||||
clCommandQueueWrapper realQueue = clCreateCommandQueue( sCurrentContext, device, 0, &error ); \
|
||||
test_error( error, "Unable to create command queue" ); \
|
||||
return fn( device, sCurrentContext, realQueue, numElements ); \
|
||||
}
|
||||
|
||||
// buffers:
|
||||
TEST_FN_REDIRECTOR( test_buffers )
|
||||
TEST_FN_REDIRECTOR( test_buffers_getinfo )
|
||||
|
||||
// 1D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_1D )
|
||||
TEST_FN_REDIRECTOR( test_images_write_1D )
|
||||
TEST_FN_REDIRECTOR( test_images_1D_getinfo )
|
||||
|
||||
// 1D image arrays:
|
||||
TEST_FN_REDIRECTOR( test_images_read_1Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_write_1Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_1Darray_getinfo )
|
||||
|
||||
// 2D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_2D )
|
||||
TEST_FN_REDIRECTOR( test_images_read_cube )
|
||||
TEST_FN_REDIRECTOR( test_images_write )
|
||||
TEST_FN_REDIRECTOR( test_images_write_cube )
|
||||
TEST_FN_REDIRECTOR( test_images_2D_getinfo )
|
||||
TEST_FN_REDIRECTOR( test_images_cube_getinfo )
|
||||
|
||||
// 2D image arrays:
|
||||
TEST_FN_REDIRECTOR( test_images_read_2Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_write_2Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_2Darray_getinfo )
|
||||
|
||||
// 3D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_3D )
|
||||
TEST_FN_REDIRECTOR( test_images_write_3D )
|
||||
TEST_FN_REDIRECTOR( test_images_3D_getinfo )
|
||||
|
||||
// Renderbuffer-backed images:
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_read )
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_write )
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_getinfo )
|
||||
|
||||
TEST_FN_REDIRECTOR( test_fence_sync )
|
||||
|
||||
basefn basefn_list[] = {
|
||||
TEST_FN_REDIRECT( test_buffers ),
|
||||
TEST_FN_REDIRECT( test_buffers_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_1D ),
|
||||
TEST_FN_REDIRECT( test_images_write_1D ),
|
||||
TEST_FN_REDIRECT( test_images_1D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_1Darray ),
|
||||
TEST_FN_REDIRECT( test_images_write_1Darray ),
|
||||
TEST_FN_REDIRECT( test_images_1Darray_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_2D ),
|
||||
TEST_FN_REDIRECT( test_images_write ),
|
||||
TEST_FN_REDIRECT( test_images_2D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_cube ),
|
||||
TEST_FN_REDIRECT( test_images_write_cube ),
|
||||
TEST_FN_REDIRECT( test_images_cube_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_2Darray ),
|
||||
TEST_FN_REDIRECT( test_images_write_2Darray),
|
||||
TEST_FN_REDIRECT( test_images_2Darray_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_3D ),
|
||||
TEST_FN_REDIRECT( test_images_write_3D ),
|
||||
TEST_FN_REDIRECT( test_images_3D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_renderbuffer_read ),
|
||||
TEST_FN_REDIRECT( test_renderbuffer_write ),
|
||||
TEST_FN_REDIRECT( test_renderbuffer_getinfo )
|
||||
};
|
||||
|
||||
basefn basefn_list32[] = {
|
||||
TEST_FN_REDIRECT( test_fence_sync )
|
||||
};
|
||||
|
||||
const char *basefn_names[] = {
|
||||
"buffers",
|
||||
"buffers_getinfo",
|
||||
|
||||
"images_read_1D",
|
||||
"images_write_1D",
|
||||
"images_1D_getinfo",
|
||||
|
||||
"images_read_1Darray",
|
||||
"images_write_1Darray",
|
||||
"images_1Darray_getinfo",
|
||||
|
||||
"images_read", /* 2D */
|
||||
"images_write",
|
||||
"images_2D_getinfo",
|
||||
|
||||
"images_read_cube",
|
||||
"images_write_cube",
|
||||
"images_cube_getinfo",
|
||||
|
||||
"images_read_2Darray",
|
||||
"images_write_2Darray",
|
||||
"images_2Darray_getinfo",
|
||||
|
||||
"images_read_3D",
|
||||
"images_write_3D",
|
||||
"images_3D_getinfo",
|
||||
|
||||
"renderbuffer_read",
|
||||
"renderbuffer_write",
|
||||
"renderbuffer_getinfo",
|
||||
|
||||
"all"
|
||||
};
|
||||
|
||||
const char *basefn_names32[] = {
|
||||
"fence_sync",
|
||||
"all"
|
||||
};
|
||||
|
||||
ct_assert((sizeof(basefn_names) / sizeof(basefn_names[0]) - 1) == (sizeof(basefn_list) / sizeof(basefn_list[0])));
|
||||
|
||||
int num_fns = sizeof(basefn_names) / sizeof(char *);
|
||||
int num_fns32 = sizeof(basefn_names32) / sizeof(char *);
|
||||
|
||||
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
bool gTestRounding = true;
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
test_start();
|
||||
|
||||
cl_device_type requestedDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
checkDeviceTypeOverride(&requestedDeviceType);
|
||||
if (requestedDeviceType != CL_DEVICE_TYPE_GPU) {
|
||||
log_info("GL tests can only run on a GPU device.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
gDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
|
||||
if( argc > 1 && strcmp( argv[ 1 ], "-list" ) == 0 )
|
||||
{
|
||||
log_info( "Available 2.x tests:\n" );
|
||||
for( int i = 0; i < num_fns - 1; i++ )
|
||||
log_info( "\t%s\n", basefn_names[ i ] );
|
||||
|
||||
log_info( "Available 3.2 tests:\n" );
|
||||
for( int i = 0; i < num_fns32 - 1; i++ )
|
||||
log_info( "\t%s\n", basefn_names32[ i ] );
|
||||
|
||||
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" );
|
||||
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check to see if any 2.x or 3.2 test names were specified on the command line.
|
||||
unsigned first_32_testname = 0;
|
||||
|
||||
for (int j=1; (j<argc) && (!first_32_testname); ++j)
|
||||
for (int i=0;i<num_fns32-1;++i)
|
||||
if (strcmp(basefn_names32[i],argv[j])==0) {
|
||||
first_32_testname = j;
|
||||
break;
|
||||
}
|
||||
|
||||
// Create the environment for the test.
|
||||
GLEnvironment *glEnv = GLEnvironment::Instance();
|
||||
|
||||
// Check if any devices of the requested type support CL/GL interop.
|
||||
int supported = glEnv->SupportsCLGLInterop( requestedDeviceType );
|
||||
if( supported == 0 ) {
|
||||
log_info("Test not run because GL-CL interop is not supported for any devices of the requested type.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
} else if ( supported == -1 ) {
|
||||
log_error("Unable to setup the test or failed to determine if CL-GL interop is supported.\n");
|
||||
test_finish();
|
||||
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");
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||
if (deviceIDs == NULL) {
|
||||
print_error( error, "malloc failed" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
numDevices /= sizeof(cl_device_id);
|
||||
|
||||
if (numDevices < 1) {
|
||||
log_error("No devices found.\n");
|
||||
test_finish();
|
||||
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 ) {
|
||||
test_finish();
|
||||
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 ], num_fns, basefn_list, basefn_names, true, 0, 1024 );
|
||||
if( error != 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
// 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");
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||
if (deviceIDs == NULL) {
|
||||
print_error( error, "malloc failed" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
numDevices /= sizeof(cl_device_id);
|
||||
|
||||
if (numDevices < 1) {
|
||||
log_error("No devices found.\n");
|
||||
test_finish();
|
||||
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 ) {
|
||||
test_finish();
|
||||
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 ], num_fns32, basefn_list32, basefn_names32, true, 0, 1024 );
|
||||
if( error != 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
// Clean-up.
|
||||
free(deviceIDs);
|
||||
clReleaseContext( sCurrentContext );
|
||||
delete glEnv;
|
||||
|
||||
}
|
||||
|
||||
//All done.
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
|
||||
#include "procs.h"
|
||||
#include "../../test_common/gl/setup.h"
|
||||
#include "../../test_common/harness/testHarness.h"
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static cl_context sCurrentContext = NULL;
|
||||
|
||||
|
||||
#define TEST_FN_REDIRECT( fn ) redirect_##fn
|
||||
#define TEST_FN_REDIRECTOR( fn ) \
|
||||
int redirect_##fn(cl_device_id device, cl_context context, cl_command_queue queue, int numElements ) \
|
||||
{ \
|
||||
int error; \
|
||||
clCommandQueueWrapper realQueue = clCreateCommandQueue( sCurrentContext, device, 0, &error ); \
|
||||
test_error( error, "Unable to create command queue" ); \
|
||||
return fn( device, sCurrentContext, realQueue, numElements ); \
|
||||
}
|
||||
|
||||
// buffers:
|
||||
TEST_FN_REDIRECTOR( test_buffers )
|
||||
TEST_FN_REDIRECTOR( test_buffers_getinfo )
|
||||
|
||||
// 1D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_1D )
|
||||
TEST_FN_REDIRECTOR( test_images_write_1D )
|
||||
TEST_FN_REDIRECTOR( test_images_1D_getinfo )
|
||||
|
||||
// 1D image arrays:
|
||||
TEST_FN_REDIRECTOR( test_images_read_1Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_write_1Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_1Darray_getinfo )
|
||||
|
||||
// 2D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_2D )
|
||||
TEST_FN_REDIRECTOR( test_images_read_cube )
|
||||
TEST_FN_REDIRECTOR( test_images_write )
|
||||
TEST_FN_REDIRECTOR( test_images_write_cube )
|
||||
TEST_FN_REDIRECTOR( test_images_2D_getinfo )
|
||||
TEST_FN_REDIRECTOR( test_images_cube_getinfo )
|
||||
|
||||
// 2D image arrays:
|
||||
TEST_FN_REDIRECTOR( test_images_read_2Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_write_2Darray )
|
||||
TEST_FN_REDIRECTOR( test_images_2Darray_getinfo )
|
||||
|
||||
// 3D images:
|
||||
TEST_FN_REDIRECTOR( test_images_read_3D )
|
||||
TEST_FN_REDIRECTOR( test_images_write_3D )
|
||||
TEST_FN_REDIRECTOR( test_images_3D_getinfo )
|
||||
|
||||
// Renderbuffer-backed images:
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_read )
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_write )
|
||||
TEST_FN_REDIRECTOR( test_renderbuffer_getinfo )
|
||||
|
||||
TEST_FN_REDIRECTOR( test_fence_sync )
|
||||
|
||||
basefn basefn_list[] = {
|
||||
TEST_FN_REDIRECT( test_buffers ),
|
||||
TEST_FN_REDIRECT( test_buffers_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_1D ),
|
||||
TEST_FN_REDIRECT( test_images_write_1D ),
|
||||
TEST_FN_REDIRECT( test_images_1D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_1Darray ),
|
||||
TEST_FN_REDIRECT( test_images_write_1Darray ),
|
||||
TEST_FN_REDIRECT( test_images_1Darray_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_2D ),
|
||||
TEST_FN_REDIRECT( test_images_write ),
|
||||
TEST_FN_REDIRECT( test_images_2D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_cube ),
|
||||
TEST_FN_REDIRECT( test_images_write_cube ),
|
||||
TEST_FN_REDIRECT( test_images_cube_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_2Darray ),
|
||||
TEST_FN_REDIRECT( test_images_write_2Darray),
|
||||
TEST_FN_REDIRECT( test_images_2Darray_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_images_read_3D ),
|
||||
TEST_FN_REDIRECT( test_images_write_3D ),
|
||||
TEST_FN_REDIRECT( test_images_3D_getinfo ),
|
||||
|
||||
TEST_FN_REDIRECT( test_renderbuffer_read ),
|
||||
TEST_FN_REDIRECT( test_renderbuffer_write ),
|
||||
TEST_FN_REDIRECT( test_renderbuffer_getinfo )
|
||||
};
|
||||
|
||||
basefn basefn_list32[] = {
|
||||
TEST_FN_REDIRECT( test_fence_sync )
|
||||
};
|
||||
|
||||
const char *basefn_names[] = {
|
||||
"buffers",
|
||||
"buffers_getinfo",
|
||||
|
||||
"images_read_1D",
|
||||
"images_write_1D",
|
||||
"images_1D_getinfo",
|
||||
|
||||
"images_read_1Darray",
|
||||
"images_write_1Darray",
|
||||
"images_1Darray_getinfo",
|
||||
|
||||
"images_read", /* 2D */
|
||||
"images_write",
|
||||
"images_2D_getinfo",
|
||||
|
||||
"images_read_cube",
|
||||
"images_write_cube",
|
||||
"images_cube_getinfo",
|
||||
|
||||
"images_read_2Darray",
|
||||
"images_write_2Darray",
|
||||
"images_2Darray_getinfo",
|
||||
|
||||
"images_read_3D",
|
||||
"images_write_3D",
|
||||
"images_3D_getinfo",
|
||||
|
||||
"renderbuffer_read",
|
||||
"renderbuffer_write",
|
||||
"renderbuffer_getinfo",
|
||||
|
||||
"all"
|
||||
};
|
||||
|
||||
const char *basefn_names32[] = {
|
||||
"fence_sync",
|
||||
"all"
|
||||
};
|
||||
|
||||
ct_assert((sizeof(basefn_names) / sizeof(basefn_names[0]) - 1) == (sizeof(basefn_list) / sizeof(basefn_list[0])));
|
||||
|
||||
int num_fns = sizeof(basefn_names) / sizeof(char *);
|
||||
int num_fns32 = sizeof(basefn_names32) / sizeof(char *);
|
||||
|
||||
cl_device_type gDeviceType = CL_DEVICE_TYPE_DEFAULT;
|
||||
bool gTestRounding = true;
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
test_start();
|
||||
|
||||
cl_device_type requestedDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
checkDeviceTypeOverride(&requestedDeviceType);
|
||||
if (requestedDeviceType != CL_DEVICE_TYPE_GPU) {
|
||||
log_info("GL tests can only run on a GPU device.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
gDeviceType = CL_DEVICE_TYPE_GPU;
|
||||
|
||||
if( argc > 1 && strcmp( argv[ 1 ], "-list" ) == 0 )
|
||||
{
|
||||
log_info( "Available 2.x tests:\n" );
|
||||
for( int i = 0; i < num_fns - 1; i++ )
|
||||
log_info( "\t%s\n", basefn_names[ i ] );
|
||||
|
||||
log_info( "Available 3.2 tests:\n" );
|
||||
for( int i = 0; i < num_fns32 - 1; i++ )
|
||||
log_info( "\t%s\n", basefn_names32[ i ] );
|
||||
|
||||
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" );
|
||||
|
||||
test_finish();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check to see if any 2.x or 3.2 test names were specified on the command line.
|
||||
unsigned first_32_testname = 0;
|
||||
|
||||
for (int j=1; (j<argc) && (!first_32_testname); ++j)
|
||||
for (int i=0;i<num_fns32-1;++i)
|
||||
if (strcmp(basefn_names32[i],argv[j])==0) {
|
||||
first_32_testname = j;
|
||||
break;
|
||||
}
|
||||
|
||||
// Create the environment for the test.
|
||||
GLEnvironment *glEnv = GLEnvironment::Instance();
|
||||
|
||||
// Check if any devices of the requested type support CL/GL interop.
|
||||
int supported = glEnv->SupportsCLGLInterop( requestedDeviceType );
|
||||
if( supported == 0 ) {
|
||||
log_info("Test not run because GL-CL interop is not supported for any devices of the requested type.\n");
|
||||
test_finish();
|
||||
return 0;
|
||||
} else if ( supported == -1 ) {
|
||||
log_error("Unable to setup the test or failed to determine if CL-GL interop is supported.\n");
|
||||
test_finish();
|
||||
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");
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||
if (deviceIDs == NULL) {
|
||||
print_error( error, "malloc failed" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
numDevices /= sizeof(cl_device_id);
|
||||
|
||||
if (numDevices < 1) {
|
||||
log_error("No devices found.\n");
|
||||
test_finish();
|
||||
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 ) {
|
||||
test_finish();
|
||||
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 ], num_fns, basefn_list, basefn_names, true, 0, 1024 );
|
||||
if( error != 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
// 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");
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
deviceIDs = (cl_device_id *)malloc(numDevices);
|
||||
if (deviceIDs == NULL) {
|
||||
print_error( error, "malloc failed" );
|
||||
test_finish();
|
||||
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" );
|
||||
test_finish();
|
||||
return -1;
|
||||
}
|
||||
|
||||
numDevices /= sizeof(cl_device_id);
|
||||
|
||||
if (numDevices < 1) {
|
||||
log_error("No devices found.\n");
|
||||
test_finish();
|
||||
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 ) {
|
||||
test_finish();
|
||||
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 ], num_fns32, basefn_list32, basefn_names32, true, 0, 1024 );
|
||||
if( error != 0 )
|
||||
break;
|
||||
}
|
||||
|
||||
// Clean-up.
|
||||
free(deviceIDs);
|
||||
clReleaseContext( sCurrentContext );
|
||||
delete glEnv;
|
||||
|
||||
}
|
||||
|
||||
//All done.
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,107 +1,107 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "../../test_common/harness/mt19937.h"
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma Misc tests
|
||||
|
||||
extern int test_buffers( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_fence_sync( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Tead tests
|
||||
|
||||
extern int test_images_read_2D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_renderbuffer_read( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Write tests
|
||||
|
||||
// 2D tests are the ones with no suffix:
|
||||
|
||||
extern int test_images_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_renderbuffer_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
// Here are the rest:
|
||||
|
||||
extern int test_images_write_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Get info test entry points
|
||||
|
||||
extern int test_buffers_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_renderbuffer_getinfo( cl_device_id device, cl_context context,
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "../../test_common/harness/mt19937.h"
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma Misc tests
|
||||
|
||||
extern int test_buffers( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_fence_sync( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Tead tests
|
||||
|
||||
extern int test_images_read_2D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_read_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_renderbuffer_read( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Write tests
|
||||
|
||||
// 2D tests are the ones with no suffix:
|
||||
|
||||
extern int test_images_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_renderbuffer_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
// Here are the rest:
|
||||
|
||||
extern int test_images_write_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
extern int test_images_write_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int num_elements );
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Get info test entry points
|
||||
|
||||
extern int test_buffers_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
|
||||
extern int test_renderbuffer_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements );
|
||||
@@ -1,68 +1,68 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef _testBase_h
|
||||
#define _testBase_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl.h>
|
||||
#include "../../test_common/gl/gl_headers.h"
|
||||
#include <CL/cl_gl.h>
|
||||
#else
|
||||
#include "../../test_common/gl/gl_headers.h"
|
||||
#endif
|
||||
|
||||
#include "../../test_common/harness/errorHelpers.h"
|
||||
#include "../../test_common/harness/kernelHelpers.h"
|
||||
#include "../../test_common/harness/threadTesting.h"
|
||||
#include "../../test_common/harness/typeWrappers.h"
|
||||
#include "../../test_common/harness/conversions.h"
|
||||
#include "../../test_common/harness/mt19937.h"
|
||||
|
||||
#include "../../test_common/gl/helpers.h"
|
||||
#include "../images/image_helpers.h"
|
||||
|
||||
extern const char *get_kernel_suffix( cl_image_format *format );
|
||||
extern const char *get_write_conversion( cl_image_format *format, ExplicitType type);
|
||||
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 );
|
||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t typeSize );
|
||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t typeSize );
|
||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height );
|
||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth );
|
||||
|
||||
extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type, GLuint expected_gl_name,
|
||||
GLenum expected_cl_gl_texture_target, GLint expected_cl_gl_mipmap_level);
|
||||
|
||||
extern bool CheckGLIntegerExtensionSupport();
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#ifndef _testBase_h
|
||||
#define _testBase_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl.h>
|
||||
#include "../../test_common/gl/gl_headers.h"
|
||||
#include <CL/cl_gl.h>
|
||||
#else
|
||||
#include "../../test_common/gl/gl_headers.h"
|
||||
#endif
|
||||
|
||||
#include "../../test_common/harness/errorHelpers.h"
|
||||
#include "../../test_common/harness/kernelHelpers.h"
|
||||
#include "../../test_common/harness/threadTesting.h"
|
||||
#include "../../test_common/harness/typeWrappers.h"
|
||||
#include "../../test_common/harness/conversions.h"
|
||||
#include "../../test_common/harness/mt19937.h"
|
||||
|
||||
#include "../../test_common/gl/helpers.h"
|
||||
#include "../images/image_helpers.h"
|
||||
|
||||
extern const char *get_kernel_suffix( cl_image_format *format );
|
||||
extern const char *get_write_conversion( cl_image_format *format, ExplicitType type);
|
||||
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 );
|
||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t typeSize );
|
||||
extern int validate_integer_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth, size_t typeSize );
|
||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height );
|
||||
extern int validate_float_results( void *expectedResults, void *actualResults, size_t width, size_t height, size_t depth );
|
||||
|
||||
extern int CheckGLObjectInfo(cl_mem mem, cl_gl_object_type expected_cl_gl_type, GLuint expected_gl_name,
|
||||
GLenum expected_cl_gl_texture_target, GLint expected_cl_gl_mipmap_level);
|
||||
|
||||
extern bool CheckGLIntegerExtensionSupport();
|
||||
|
||||
#endif // _testBase_h
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,359 +1,359 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "../../test_common/harness/conversions.h"
|
||||
#include "../../test_common/harness/typeWrappers.h"
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static const char *bufferKernelPattern =
|
||||
"__kernel void sample_test( __global %s%s *source, __global %s%s *clDest, __global %s%s *glDest )\n"
|
||||
"{\n"
|
||||
" int tid = get_global_id(0);\n"
|
||||
" clDest[ tid ] = source[ tid ] + (%s%s)(1);\n"
|
||||
" glDest[ tid ] = source[ tid ] + (%s%s)(2);\n"
|
||||
"}\n";
|
||||
|
||||
#define TYPE_CASE( enum, type, range, offset ) \
|
||||
case enum: \
|
||||
{ \
|
||||
cl_##type *ptr = (cl_##type *)outData; \
|
||||
for( i = 0; i < count; i++ ) \
|
||||
ptr[ i ] = (cl_##type)( ( genrand_int32(d) & range ) - offset ); \
|
||||
break; \
|
||||
}
|
||||
|
||||
void gen_input_data( ExplicitType type, size_t count, MTdata d, void *outData )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case kBool:
|
||||
{
|
||||
bool *boolPtr = (bool *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
boolPtr[i] = ( genrand_int32(d) & 1 ) ? true : false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
TYPE_CASE( kChar, char, 250, 127 )
|
||||
TYPE_CASE( kUChar, uchar, 250, 0 )
|
||||
TYPE_CASE( kShort, short, 65530, 32767 )
|
||||
TYPE_CASE( kUShort, ushort, 65530, 0 )
|
||||
TYPE_CASE( kInt, int, 0x0fffffff, 0x70000000 )
|
||||
TYPE_CASE( kUInt, uint, 0x0fffffff, 0 )
|
||||
|
||||
case kLong:
|
||||
{
|
||||
cl_long *longPtr = (cl_long *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
longPtr[i] = (cl_long)genrand_int32(d) | ( (cl_ulong)genrand_int32(d) << 32 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kULong:
|
||||
{
|
||||
cl_ulong *ulongPtr = (cl_ulong *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
ulongPtr[i] = (cl_ulong)genrand_int32(d) | ( (cl_ulong)genrand_int32(d) << 32 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kFloat:
|
||||
{
|
||||
cl_float *floatPtr = (float *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
floatPtr[i] = get_random_float( -100000.f, 100000.f, d );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
log_error( "ERROR: Invalid type passed in to generate_random_data!\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define INC_CASE( enum, type ) \
|
||||
case enum: \
|
||||
{ \
|
||||
cl_##type *src = (cl_##type *)inData; \
|
||||
cl_##type *dst = (cl_##type *)outData; \
|
||||
*dst = *src + 1; \
|
||||
break; \
|
||||
}
|
||||
|
||||
void get_incremented_value( void *inData, void *outData, ExplicitType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
INC_CASE( kChar, char )
|
||||
INC_CASE( kUChar, uchar )
|
||||
INC_CASE( kShort, short )
|
||||
INC_CASE( kUShort, ushort )
|
||||
INC_CASE( kInt, int )
|
||||
INC_CASE( kUInt, uint )
|
||||
INC_CASE( kLong, long )
|
||||
INC_CASE( kULong, ulong )
|
||||
INC_CASE( kFloat, float )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int test_buffer_kernel(cl_context context, cl_command_queue queue, ExplicitType vecType, size_t vecSize, int numElements, int validate_only, MTdata d)
|
||||
{
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
clMemWrapper streams[ 3 ];
|
||||
size_t dataSize = numElements * 16 * sizeof(cl_long);
|
||||
#if !(defined(_WIN32) && defined(_MSC_VER))
|
||||
cl_long inData[numElements * 16], outDataCL[numElements * 16], outDataGL[ numElements * 16 ];
|
||||
#else
|
||||
cl_long* inData = (cl_long*)_malloca(dataSize);
|
||||
cl_long* outDataCL = (cl_long*)_malloca(dataSize);
|
||||
cl_long* outDataGL = (cl_long*)_malloca(dataSize);
|
||||
#endif
|
||||
glBufferWrapper inGLBuffer, outGLBuffer;
|
||||
int i;
|
||||
size_t bufferSize;
|
||||
|
||||
int error;
|
||||
size_t threads[1], localThreads[1];
|
||||
char kernelSource[10240];
|
||||
char *programPtr;
|
||||
char sizeName[4];
|
||||
|
||||
/* Create the source */
|
||||
if( vecSize == 1 )
|
||||
sizeName[ 0 ] = 0;
|
||||
else
|
||||
sprintf( sizeName, "%d", (int)vecSize );
|
||||
|
||||
sprintf( kernelSource, bufferKernelPattern, get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName );
|
||||
|
||||
/* Create kernels */
|
||||
programPtr = kernelSource;
|
||||
if( create_single_kernel_helper( context, &program, &kernel, 1, (const char **)&programPtr, "sample_test" ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bufferSize = numElements * vecSize * get_explicit_type_size( vecType );
|
||||
|
||||
/* Generate some almost-random input data */
|
||||
gen_input_data( vecType, vecSize * numElements, d, inData );
|
||||
memset( outDataCL, 0, dataSize );
|
||||
memset( outDataGL, 0, dataSize );
|
||||
|
||||
/* Generate some GL buffers to go against */
|
||||
glGenBuffers( 1, &inGLBuffer );
|
||||
glGenBuffers( 1, &outGLBuffer );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, inGLBuffer );
|
||||
glBufferData( GL_ARRAY_BUFFER, bufferSize, inData, GL_STATIC_DRAW );
|
||||
|
||||
// Note: we need to bind the output buffer, even though we don't care about its values yet,
|
||||
// because CL needs it to get the buffer size
|
||||
glBindBuffer( GL_ARRAY_BUFFER, outGLBuffer );
|
||||
glBufferData( GL_ARRAY_BUFFER, bufferSize, outDataGL, GL_STATIC_DRAW );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
glFlush();
|
||||
|
||||
|
||||
/* Generate some streams. The first and last ones are GL, middle one just vanilla CL */
|
||||
streams[ 0 ] = (*clCreateFromGLBuffer_ptr)( context, CL_MEM_READ_ONLY, inGLBuffer, &error );
|
||||
test_error( error, "Unable to create input GL buffer" );
|
||||
|
||||
streams[ 1 ] = clCreateBuffer( context, CL_MEM_READ_WRITE, bufferSize, NULL, &error );
|
||||
test_error( error, "Unable to create output CL buffer" );
|
||||
|
||||
streams[ 2 ] = (*clCreateFromGLBuffer_ptr)( context, CL_MEM_WRITE_ONLY, outGLBuffer, &error );
|
||||
test_error( error, "Unable to create output GL buffer" );
|
||||
|
||||
|
||||
/* Validate the info */
|
||||
if (validate_only) {
|
||||
int result = (CheckGLObjectInfo(streams[0], CL_GL_OBJECT_BUFFER, (GLuint)inGLBuffer, (GLenum)0, 0) |
|
||||
CheckGLObjectInfo(streams[2], CL_GL_OBJECT_BUFFER, (GLuint)outGLBuffer, (GLenum)0, 0) );
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
clReleaseMemObject(streams[i]);
|
||||
streams[i] = NULL;
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &inGLBuffer); inGLBuffer = 0;
|
||||
glDeleteBuffers(1, &outGLBuffer); outGLBuffer = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Assign streams and execute */
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
error = clSetKernelArg( kernel, i, sizeof( streams[ i ] ), &streams[ i ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
}
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 2 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
|
||||
/* Run the kernel */
|
||||
threads[0] = numElements;
|
||||
|
||||
error = get_max_common_work_group_size( context, kernel, threads[0], &localThreads[0] );
|
||||
test_error( error, "Unable to get work group size to use" );
|
||||
|
||||
error = clEnqueueNDRangeKernel( queue, kernel, 1, NULL, threads, localThreads, 0, NULL, NULL );
|
||||
test_error( error, "Unable to execute test kernel" );
|
||||
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 2 ], 0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
|
||||
// Get the results from both CL and GL and make sure everything looks correct
|
||||
error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, bufferSize, outDataCL, 0, NULL, NULL );
|
||||
test_error( error, "Unable to read output CL array!" );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, outGLBuffer );
|
||||
void *glMem = glMapBuffer( GL_ARRAY_BUFFER, GL_READ_ONLY );
|
||||
memcpy( outDataGL, glMem, bufferSize );
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER );
|
||||
|
||||
char *inP = (char *)inData, *glP = (char *)outDataGL, *clP = (char *)outDataCL;
|
||||
error = 0;
|
||||
for( size_t i = 0; i < numElements * vecSize; i++ )
|
||||
{
|
||||
cl_long expectedCLValue, expectedGLValue;
|
||||
get_incremented_value( inP, &expectedCLValue, vecType );
|
||||
get_incremented_value( &expectedCLValue, &expectedGLValue, vecType );
|
||||
|
||||
if( memcmp( clP, &expectedCLValue, get_explicit_type_size( vecType ) ) != 0 )
|
||||
{
|
||||
char scratch[ 64 ];
|
||||
log_error( "ERROR: Data sample %d from the CL output did not validate!\n", (int)i );
|
||||
log_error( "\t Input: %s\n", GetDataVectorString( inP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\tExpected: %s\n", GetDataVectorString( &expectedCLValue, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\t Actual: %s\n", GetDataVectorString( clP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
error = -1;
|
||||
}
|
||||
|
||||
if( memcmp( glP, &expectedGLValue, get_explicit_type_size( vecType ) ) != 0 )
|
||||
{
|
||||
char scratch[ 64 ];
|
||||
log_error( "ERROR: Data sample %d from the GL output did not validate!\n", (int)i );
|
||||
log_error( "\t Input: %s\n", GetDataVectorString( inP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\tExpected: %s\n", GetDataVectorString( &expectedGLValue, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\t Actual: %s\n", GetDataVectorString( glP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
error = -1;
|
||||
}
|
||||
|
||||
if( error )
|
||||
return error;
|
||||
|
||||
inP += get_explicit_type_size( vecType );
|
||||
glP += get_explicit_type_size( vecType );
|
||||
clP += get_explicit_type_size( vecType );
|
||||
}
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
clReleaseMemObject(streams[i]);
|
||||
streams[i] = NULL;
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &inGLBuffer); inGLBuffer = 0;
|
||||
glDeleteBuffers(1, &outGLBuffer); outGLBuffer = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_buffers( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, kFloat, kNumExplicitTypes };
|
||||
unsigned int vecSizes[] = { 1, 2, 4, 8, 16, 0 };
|
||||
unsigned int index, typeIndex;
|
||||
int retVal = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
|
||||
for( typeIndex = 0; vecType[ typeIndex ] != kNumExplicitTypes; typeIndex++ )
|
||||
{
|
||||
for( index = 0; vecSizes[ index ] != 0; index++ )
|
||||
{
|
||||
// Test!
|
||||
if( test_buffer_kernel( context, queue, vecType[ typeIndex ], vecSizes[ index ], numElements, 0, seed) != 0 )
|
||||
{
|
||||
char sizeNames[][ 4 ] = { "", "", "2", "", "4", "", "", "", "8", "", "", "", "", "", "", "", "16" };
|
||||
log_error( " Buffer test %s%s FAILED\n", get_explicit_type_name( vecType[ typeIndex ] ), sizeNames[ vecSizes[ index ] ] );
|
||||
retVal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int test_buffers_getinfo( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, kFloat, kNumExplicitTypes };
|
||||
unsigned int vecSizes[] = { 1, 2, 4, 8, 16, 0 };
|
||||
unsigned int index, typeIndex;
|
||||
int retVal = 0;
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
|
||||
for( typeIndex = 0; vecType[ typeIndex ] != kNumExplicitTypes; typeIndex++ )
|
||||
{
|
||||
for( index = 0; vecSizes[ index ] != 0; index++ )
|
||||
{
|
||||
// Test!
|
||||
if( test_buffer_kernel( context, queue, vecType[ typeIndex ], vecSizes[ index ], numElements, 1, seed ) != 0 )
|
||||
{
|
||||
char sizeNames[][ 4 ] = { "", "", "2", "", "4", "", "", "", "8", "", "", "", "", "", "", "", "16" };
|
||||
log_error( " Buffer test %s%s FAILED\n", get_explicit_type_name( vecType[ typeIndex ] ), sizeNames[ vecSizes[ index ] ] );
|
||||
retVal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "../../test_common/harness/conversions.h"
|
||||
#include "../../test_common/harness/typeWrappers.h"
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static const char *bufferKernelPattern =
|
||||
"__kernel void sample_test( __global %s%s *source, __global %s%s *clDest, __global %s%s *glDest )\n"
|
||||
"{\n"
|
||||
" int tid = get_global_id(0);\n"
|
||||
" clDest[ tid ] = source[ tid ] + (%s%s)(1);\n"
|
||||
" glDest[ tid ] = source[ tid ] + (%s%s)(2);\n"
|
||||
"}\n";
|
||||
|
||||
#define TYPE_CASE( enum, type, range, offset ) \
|
||||
case enum: \
|
||||
{ \
|
||||
cl_##type *ptr = (cl_##type *)outData; \
|
||||
for( i = 0; i < count; i++ ) \
|
||||
ptr[ i ] = (cl_##type)( ( genrand_int32(d) & range ) - offset ); \
|
||||
break; \
|
||||
}
|
||||
|
||||
void gen_input_data( ExplicitType type, size_t count, MTdata d, void *outData )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
switch( type )
|
||||
{
|
||||
case kBool:
|
||||
{
|
||||
bool *boolPtr = (bool *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
boolPtr[i] = ( genrand_int32(d) & 1 ) ? true : false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
TYPE_CASE( kChar, char, 250, 127 )
|
||||
TYPE_CASE( kUChar, uchar, 250, 0 )
|
||||
TYPE_CASE( kShort, short, 65530, 32767 )
|
||||
TYPE_CASE( kUShort, ushort, 65530, 0 )
|
||||
TYPE_CASE( kInt, int, 0x0fffffff, 0x70000000 )
|
||||
TYPE_CASE( kUInt, uint, 0x0fffffff, 0 )
|
||||
|
||||
case kLong:
|
||||
{
|
||||
cl_long *longPtr = (cl_long *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
longPtr[i] = (cl_long)genrand_int32(d) | ( (cl_ulong)genrand_int32(d) << 32 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kULong:
|
||||
{
|
||||
cl_ulong *ulongPtr = (cl_ulong *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
{
|
||||
ulongPtr[i] = (cl_ulong)genrand_int32(d) | ( (cl_ulong)genrand_int32(d) << 32 );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case kFloat:
|
||||
{
|
||||
cl_float *floatPtr = (float *)outData;
|
||||
for( i = 0; i < count; i++ )
|
||||
floatPtr[i] = get_random_float( -100000.f, 100000.f, d );
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
log_error( "ERROR: Invalid type passed in to generate_random_data!\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#define INC_CASE( enum, type ) \
|
||||
case enum: \
|
||||
{ \
|
||||
cl_##type *src = (cl_##type *)inData; \
|
||||
cl_##type *dst = (cl_##type *)outData; \
|
||||
*dst = *src + 1; \
|
||||
break; \
|
||||
}
|
||||
|
||||
void get_incremented_value( void *inData, void *outData, ExplicitType type )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
INC_CASE( kChar, char )
|
||||
INC_CASE( kUChar, uchar )
|
||||
INC_CASE( kShort, short )
|
||||
INC_CASE( kUShort, ushort )
|
||||
INC_CASE( kInt, int )
|
||||
INC_CASE( kUInt, uint )
|
||||
INC_CASE( kLong, long )
|
||||
INC_CASE( kULong, ulong )
|
||||
INC_CASE( kFloat, float )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int test_buffer_kernel(cl_context context, cl_command_queue queue, ExplicitType vecType, size_t vecSize, int numElements, int validate_only, MTdata d)
|
||||
{
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
clMemWrapper streams[ 3 ];
|
||||
size_t dataSize = numElements * 16 * sizeof(cl_long);
|
||||
#if !(defined(_WIN32) && defined(_MSC_VER))
|
||||
cl_long inData[numElements * 16], outDataCL[numElements * 16], outDataGL[ numElements * 16 ];
|
||||
#else
|
||||
cl_long* inData = (cl_long*)_malloca(dataSize);
|
||||
cl_long* outDataCL = (cl_long*)_malloca(dataSize);
|
||||
cl_long* outDataGL = (cl_long*)_malloca(dataSize);
|
||||
#endif
|
||||
glBufferWrapper inGLBuffer, outGLBuffer;
|
||||
int i;
|
||||
size_t bufferSize;
|
||||
|
||||
int error;
|
||||
size_t threads[1], localThreads[1];
|
||||
char kernelSource[10240];
|
||||
char *programPtr;
|
||||
char sizeName[4];
|
||||
|
||||
/* Create the source */
|
||||
if( vecSize == 1 )
|
||||
sizeName[ 0 ] = 0;
|
||||
else
|
||||
sprintf( sizeName, "%d", (int)vecSize );
|
||||
|
||||
sprintf( kernelSource, bufferKernelPattern, get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName,
|
||||
get_explicit_type_name( vecType ), sizeName );
|
||||
|
||||
/* Create kernels */
|
||||
programPtr = kernelSource;
|
||||
if( create_single_kernel_helper( context, &program, &kernel, 1, (const char **)&programPtr, "sample_test" ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
bufferSize = numElements * vecSize * get_explicit_type_size( vecType );
|
||||
|
||||
/* Generate some almost-random input data */
|
||||
gen_input_data( vecType, vecSize * numElements, d, inData );
|
||||
memset( outDataCL, 0, dataSize );
|
||||
memset( outDataGL, 0, dataSize );
|
||||
|
||||
/* Generate some GL buffers to go against */
|
||||
glGenBuffers( 1, &inGLBuffer );
|
||||
glGenBuffers( 1, &outGLBuffer );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, inGLBuffer );
|
||||
glBufferData( GL_ARRAY_BUFFER, bufferSize, inData, GL_STATIC_DRAW );
|
||||
|
||||
// Note: we need to bind the output buffer, even though we don't care about its values yet,
|
||||
// because CL needs it to get the buffer size
|
||||
glBindBuffer( GL_ARRAY_BUFFER, outGLBuffer );
|
||||
glBufferData( GL_ARRAY_BUFFER, bufferSize, outDataGL, GL_STATIC_DRAW );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, 0 );
|
||||
glFlush();
|
||||
|
||||
|
||||
/* Generate some streams. The first and last ones are GL, middle one just vanilla CL */
|
||||
streams[ 0 ] = (*clCreateFromGLBuffer_ptr)( context, CL_MEM_READ_ONLY, inGLBuffer, &error );
|
||||
test_error( error, "Unable to create input GL buffer" );
|
||||
|
||||
streams[ 1 ] = clCreateBuffer( context, CL_MEM_READ_WRITE, bufferSize, NULL, &error );
|
||||
test_error( error, "Unable to create output CL buffer" );
|
||||
|
||||
streams[ 2 ] = (*clCreateFromGLBuffer_ptr)( context, CL_MEM_WRITE_ONLY, outGLBuffer, &error );
|
||||
test_error( error, "Unable to create output GL buffer" );
|
||||
|
||||
|
||||
/* Validate the info */
|
||||
if (validate_only) {
|
||||
int result = (CheckGLObjectInfo(streams[0], CL_GL_OBJECT_BUFFER, (GLuint)inGLBuffer, (GLenum)0, 0) |
|
||||
CheckGLObjectInfo(streams[2], CL_GL_OBJECT_BUFFER, (GLuint)outGLBuffer, (GLenum)0, 0) );
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
clReleaseMemObject(streams[i]);
|
||||
streams[i] = NULL;
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &inGLBuffer); inGLBuffer = 0;
|
||||
glDeleteBuffers(1, &outGLBuffer); outGLBuffer = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Assign streams and execute */
|
||||
for( int i = 0; i < 3; i++ )
|
||||
{
|
||||
error = clSetKernelArg( kernel, i, sizeof( streams[ i ] ), &streams[ i ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
}
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 2 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
|
||||
/* Run the kernel */
|
||||
threads[0] = numElements;
|
||||
|
||||
error = get_max_common_work_group_size( context, kernel, threads[0], &localThreads[0] );
|
||||
test_error( error, "Unable to get work group size to use" );
|
||||
|
||||
error = clEnqueueNDRangeKernel( queue, kernel, 1, NULL, threads, localThreads, 0, NULL, NULL );
|
||||
test_error( error, "Unable to execute test kernel" );
|
||||
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 2 ], 0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
|
||||
// Get the results from both CL and GL and make sure everything looks correct
|
||||
error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0, bufferSize, outDataCL, 0, NULL, NULL );
|
||||
test_error( error, "Unable to read output CL array!" );
|
||||
|
||||
glBindBuffer( GL_ARRAY_BUFFER, outGLBuffer );
|
||||
void *glMem = glMapBuffer( GL_ARRAY_BUFFER, GL_READ_ONLY );
|
||||
memcpy( outDataGL, glMem, bufferSize );
|
||||
glUnmapBuffer( GL_ARRAY_BUFFER );
|
||||
|
||||
char *inP = (char *)inData, *glP = (char *)outDataGL, *clP = (char *)outDataCL;
|
||||
error = 0;
|
||||
for( size_t i = 0; i < numElements * vecSize; i++ )
|
||||
{
|
||||
cl_long expectedCLValue, expectedGLValue;
|
||||
get_incremented_value( inP, &expectedCLValue, vecType );
|
||||
get_incremented_value( &expectedCLValue, &expectedGLValue, vecType );
|
||||
|
||||
if( memcmp( clP, &expectedCLValue, get_explicit_type_size( vecType ) ) != 0 )
|
||||
{
|
||||
char scratch[ 64 ];
|
||||
log_error( "ERROR: Data sample %d from the CL output did not validate!\n", (int)i );
|
||||
log_error( "\t Input: %s\n", GetDataVectorString( inP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\tExpected: %s\n", GetDataVectorString( &expectedCLValue, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\t Actual: %s\n", GetDataVectorString( clP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
error = -1;
|
||||
}
|
||||
|
||||
if( memcmp( glP, &expectedGLValue, get_explicit_type_size( vecType ) ) != 0 )
|
||||
{
|
||||
char scratch[ 64 ];
|
||||
log_error( "ERROR: Data sample %d from the GL output did not validate!\n", (int)i );
|
||||
log_error( "\t Input: %s\n", GetDataVectorString( inP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\tExpected: %s\n", GetDataVectorString( &expectedGLValue, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
log_error( "\t Actual: %s\n", GetDataVectorString( glP, get_explicit_type_size( vecType ), 1, scratch ) );
|
||||
error = -1;
|
||||
}
|
||||
|
||||
if( error )
|
||||
return error;
|
||||
|
||||
inP += get_explicit_type_size( vecType );
|
||||
glP += get_explicit_type_size( vecType );
|
||||
clP += get_explicit_type_size( vecType );
|
||||
}
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
{
|
||||
clReleaseMemObject(streams[i]);
|
||||
streams[i] = NULL;
|
||||
}
|
||||
|
||||
glDeleteBuffers(1, &inGLBuffer); inGLBuffer = 0;
|
||||
glDeleteBuffers(1, &outGLBuffer); outGLBuffer = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_buffers( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, kFloat, kNumExplicitTypes };
|
||||
unsigned int vecSizes[] = { 1, 2, 4, 8, 16, 0 };
|
||||
unsigned int index, typeIndex;
|
||||
int retVal = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
|
||||
for( typeIndex = 0; vecType[ typeIndex ] != kNumExplicitTypes; typeIndex++ )
|
||||
{
|
||||
for( index = 0; vecSizes[ index ] != 0; index++ )
|
||||
{
|
||||
// Test!
|
||||
if( test_buffer_kernel( context, queue, vecType[ typeIndex ], vecSizes[ index ], numElements, 0, seed) != 0 )
|
||||
{
|
||||
char sizeNames[][ 4 ] = { "", "", "2", "", "4", "", "", "", "8", "", "", "", "", "", "", "", "16" };
|
||||
log_error( " Buffer test %s%s FAILED\n", get_explicit_type_name( vecType[ typeIndex ] ), sizeNames[ vecSizes[ index ] ] );
|
||||
retVal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int test_buffers_getinfo( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
ExplicitType vecType[] = { kChar, kUChar, kShort, kUShort, kInt, kUInt, kLong, kULong, kFloat, kNumExplicitTypes };
|
||||
unsigned int vecSizes[] = { 1, 2, 4, 8, 16, 0 };
|
||||
unsigned int index, typeIndex;
|
||||
int retVal = 0;
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
|
||||
for( typeIndex = 0; vecType[ typeIndex ] != kNumExplicitTypes; typeIndex++ )
|
||||
{
|
||||
for( index = 0; vecSizes[ index ] != 0; index++ )
|
||||
{
|
||||
// Test!
|
||||
if( test_buffer_kernel( context, queue, vecType[ typeIndex ], vecSizes[ index ], numElements, 1, seed ) != 0 )
|
||||
{
|
||||
char sizeNames[][ 4 ] = { "", "", "2", "", "4", "", "", "", "8", "", "", "", "", "", "", "", "16" };
|
||||
log_error( " Buffer test %s%s FAILED\n", get_explicit_type_name( vecType[ typeIndex ] ), sizeNames[ vecSizes[ index ] ] );
|
||||
retVal++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retVal;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,79 +1,79 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D, GL_TEXTURE_BUFFER };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D, GL_TEXTURE_BUFFER };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 10, 4000, seed );
|
||||
sizes[i].height = 1;
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D /*, GL_TEXTURE_BUFFER */ };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D, GL_TEXTURE_BUFFER };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_1D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D, GL_TEXTURE_BUFFER };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 10, 4000, seed );
|
||||
sizes[i].height = 1;
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_1D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D /*, GL_TEXTURE_BUFFER */ };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
@@ -1,79 +1,79 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 10, 4000, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_1Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 10, 4000, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_1Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_1D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
@@ -1,172 +1,172 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; }
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D read tests
|
||||
|
||||
int test_images_read_2D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
const size_t nsizes = 6;
|
||||
size_t sizes[nsizes];
|
||||
for (int i = 0; i < nsizes; i++) {
|
||||
sizes[i] = random_in_range(16, 512, seed);
|
||||
}
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_read_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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 nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D write tests
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int test_images_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_write_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t i;
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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]);
|
||||
|
||||
const size_t nsizes = 9;
|
||||
size_t base_size = 16;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// Generate power-of-two 2D sizes, 16-4096:
|
||||
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = sizes[i].height = base_size;
|
||||
sizes[i].depth = 1;
|
||||
base_size *= 2;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D get info tests
|
||||
|
||||
int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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 sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; }
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D read tests
|
||||
|
||||
int test_images_read_2D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
const size_t nsizes = 6;
|
||||
size_t sizes[nsizes];
|
||||
for (int i = 0; i < nsizes; i++) {
|
||||
sizes[i] = random_in_range(16, 512, seed);
|
||||
}
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_read_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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 nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D write tests
|
||||
|
||||
#include "common.h"
|
||||
|
||||
int test_images_write( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = 1;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_write_cube( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
size_t i;
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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]);
|
||||
|
||||
const size_t nsizes = 9;
|
||||
size_t base_size = 16;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// Generate power-of-two 2D sizes, 16-4096:
|
||||
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = sizes[i].height = base_size;
|
||||
sizes[i].depth = 1;
|
||||
base_size *= 2;
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _2D get info tests
|
||||
|
||||
int test_images_2D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE_EXT };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
size_t sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_cube_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = {
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_X,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
|
||||
GL_TEXTURE_CUBE_MAP_POSITIVE_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 sizes[] = { 16, 32, 64, 128, 256, 512, 1024, 2048, 4096 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
@@ -1,81 +1,81 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// FIXME: Query for 2D image array write support.
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = random_in_range( 4, 24, seed );
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
int test_images_read_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
int test_images_write_2Darray( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// FIXME: Query for 2D image array write support.
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = random_in_range( 4, 24, seed );
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
int test_images_2Darray_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int )
|
||||
{
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_2D_ARRAY };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
@@ -1,97 +1,97 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _3D read test
|
||||
|
||||
int test_images_read_3D( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = 1;
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma marm _3D write test
|
||||
|
||||
int test_images_write_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// TODO: Perhaps the expected behavior is to FAIL if 3D images are
|
||||
// unsupported?
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = random_in_range( 4, 24, seed );
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _3D get info test
|
||||
|
||||
int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = 1;
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _3D read test
|
||||
|
||||
int test_images_read_3D( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = 1;
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_read_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma marm _3D write test
|
||||
|
||||
int test_images_write_3D( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
int error = 0;
|
||||
size_t i;
|
||||
const size_t nsizes = 6;
|
||||
sizevec_t sizes[nsizes];
|
||||
|
||||
// TODO: Perhaps the expected behavior is to FAIL if 3D images are
|
||||
// unsupported?
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = sizeof(targets) / sizeof(targets[0]);
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Generate some random sizes (within reasonable ranges)
|
||||
for (i = 0; i < nsizes; i++) {
|
||||
sizes[i].width = random_in_range( 16, 512, seed );
|
||||
sizes[i].height = random_in_range( 16, 512, seed );
|
||||
sizes[i].depth = random_in_range( 4, 24, seed );
|
||||
}
|
||||
|
||||
return test_images_write_common( device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes );
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark _3D get info test
|
||||
|
||||
int test_images_3D_getinfo( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum targets[] = { GL_TEXTURE_3D };
|
||||
size_t ntargets = 1;
|
||||
|
||||
size_t sizes[] = { 2, 4, 8, 16, 32, 64, 128 };
|
||||
size_t nsizes = sizeof(sizes) / sizeof(sizes[0]);
|
||||
|
||||
size_t nformats = sizeof(common_formats) / sizeof(common_formats[0]);
|
||||
|
||||
return test_images_get_info_common(device, context, queue, common_formats,
|
||||
nformats, targets, ntargets, sizes, nsizes);
|
||||
}
|
||||
|
||||
@@ -1,215 +1,215 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static int test_image_info( cl_context context, cl_command_queue queue,
|
||||
GLenum glTarget, GLuint glTexture, size_t imageWidth, size_t imageHeight,
|
||||
size_t imageDepth, cl_image_format *outFormat, ExplicitType *outType,
|
||||
void **outResultBuffer )
|
||||
{
|
||||
clMemWrapper streams[ 2 ];
|
||||
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL texture
|
||||
streams[ 0 ] = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
||||
glTarget, 0, glTexture, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL texture" );
|
||||
GLint fmt;
|
||||
glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
||||
log_error( " Supplied GL texture was format %s\n", GetGLFormatName( fmt ) );
|
||||
return error;
|
||||
}
|
||||
|
||||
// Determine data type and format that CL came up with
|
||||
error = clGetImageInfo( streams[ 0 ], CL_IMAGE_FORMAT,
|
||||
sizeof( cl_image_format ), outFormat, NULL );
|
||||
test_error( error, "Unable to get CL image format" );
|
||||
|
||||
cl_gl_object_type object_type;
|
||||
switch (glTarget) {
|
||||
case GL_TEXTURE_1D:
|
||||
object_type = CL_GL_OBJECT_TEXTURE1D;
|
||||
break;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
object_type = CL_GL_OBJECT_TEXTURE_BUFFER;
|
||||
break;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
object_type = CL_GL_OBJECT_TEXTURE1D_ARRAY;
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
object_type = CL_GL_OBJECT_TEXTURE2D;
|
||||
break;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
object_type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
object_type = CL_GL_OBJECT_TEXTURE3D;
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return CheckGLObjectInfo(streams[0], object_type, glTexture, glTarget, 0);
|
||||
}
|
||||
|
||||
static int test_image_format_get_info(
|
||||
cl_context context, cl_command_queue queue,
|
||||
size_t width, size_t height, size_t depth,
|
||||
GLenum target, struct format* fmt, MTdata data)
|
||||
{
|
||||
int error = 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;
|
||||
|
||||
// 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:
|
||||
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 != 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,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes )
|
||||
{
|
||||
int error = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// First, ensure this device supports images.
|
||||
|
||||
if (checkForImageSupport(device)) {
|
||||
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++ ) {
|
||||
|
||||
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], sizes[sidx], sizes[sidx],
|
||||
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;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#include "common.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static int test_image_info( cl_context context, cl_command_queue queue,
|
||||
GLenum glTarget, GLuint glTexture, size_t imageWidth, size_t imageHeight,
|
||||
size_t imageDepth, cl_image_format *outFormat, ExplicitType *outType,
|
||||
void **outResultBuffer )
|
||||
{
|
||||
clMemWrapper streams[ 2 ];
|
||||
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL texture
|
||||
streams[ 0 ] = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
||||
glTarget, 0, glTexture, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL texture" );
|
||||
GLint fmt;
|
||||
glGetTexLevelParameteriv( glTarget, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
||||
log_error( " Supplied GL texture was format %s\n", GetGLFormatName( fmt ) );
|
||||
return error;
|
||||
}
|
||||
|
||||
// Determine data type and format that CL came up with
|
||||
error = clGetImageInfo( streams[ 0 ], CL_IMAGE_FORMAT,
|
||||
sizeof( cl_image_format ), outFormat, NULL );
|
||||
test_error( error, "Unable to get CL image format" );
|
||||
|
||||
cl_gl_object_type object_type;
|
||||
switch (glTarget) {
|
||||
case GL_TEXTURE_1D:
|
||||
object_type = CL_GL_OBJECT_TEXTURE1D;
|
||||
break;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
object_type = CL_GL_OBJECT_TEXTURE_BUFFER;
|
||||
break;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
object_type = CL_GL_OBJECT_TEXTURE1D_ARRAY;
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
object_type = CL_GL_OBJECT_TEXTURE2D;
|
||||
break;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
object_type = CL_GL_OBJECT_TEXTURE2D_ARRAY;
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
object_type = CL_GL_OBJECT_TEXTURE3D;
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
return CheckGLObjectInfo(streams[0], object_type, glTexture, glTarget, 0);
|
||||
}
|
||||
|
||||
static int test_image_format_get_info(
|
||||
cl_context context, cl_command_queue queue,
|
||||
size_t width, size_t height, size_t depth,
|
||||
GLenum target, struct format* fmt, MTdata data)
|
||||
{
|
||||
int error = 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;
|
||||
|
||||
// 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:
|
||||
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 != 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,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes )
|
||||
{
|
||||
int error = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// First, ensure this device supports images.
|
||||
|
||||
if (checkForImageSupport(device)) {
|
||||
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++ ) {
|
||||
|
||||
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], sizes[sidx], sizes[sidx],
|
||||
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,452 +1,452 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static const char *kernelpattern_image_read_1d =
|
||||
"__kernel void sample_test( read_only image1d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int offset = get_global_id(0);\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, offset );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_1darray =
|
||||
"__kernel void sample_test( read_only image1d_array_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" results[ tidY * get_image_width( source ) + tidX ] = read_image%s( source, sampler, (int2)( tidX, tidY ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_2d =
|
||||
"__kernel void sample_test( read_only image2d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" results[ tidY * get_image_width( source ) + tidX ] = read_image%s( source, sampler, (int2)( tidX, tidY ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_2darray =
|
||||
"__kernel void sample_test( read_only image2d_array_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" int tidZ = get_global_id(2);\n"
|
||||
" int width = get_image_width( source );\n"
|
||||
" int height = get_image_height( source );\n"
|
||||
" int offset = tidZ * width * height + tidY * width + tidX;\n"
|
||||
"\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, (int4)( tidX, tidY, tidZ, 0 ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_3d =
|
||||
"__kernel void sample_test( read_only image3d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" int tidZ = get_global_id(2);\n"
|
||||
" int width = get_image_width( source );\n"
|
||||
" int height = get_image_height( source );\n"
|
||||
" int offset = tidZ * width * height + tidY * width + tidX;\n"
|
||||
"\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, (int4)( tidX, tidY, tidZ, 0 ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char* get_appropriate_kernel_for_target(GLenum target) {
|
||||
|
||||
switch (get_base_gl_target(target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
return kernelpattern_image_read_1d;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
return kernelpattern_image_read_1darray;
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
case GL_RENDERBUFFER:
|
||||
return kernelpattern_image_read_2d;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
return kernelpattern_image_read_2darray;
|
||||
case GL_TEXTURE_3D:
|
||||
return kernelpattern_image_read_3d;
|
||||
|
||||
default:
|
||||
log_error("Unsupported texture target (%s); cannot determine "
|
||||
"appropriate kernel.", GetGLTargetName(target));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
clMemWrapper streams[ 2 ];
|
||||
|
||||
int error;
|
||||
char kernelSource[1024];
|
||||
char *programPtr;
|
||||
|
||||
// Use the image created from the GL texture.
|
||||
streams[ 0 ] = image;
|
||||
|
||||
// Determine data type and format that CL came up with
|
||||
error = clGetImageInfo( streams[ 0 ], CL_IMAGE_FORMAT, sizeof( cl_image_format ), outFormat, NULL );
|
||||
test_error( error, "Unable to get CL image format" );
|
||||
|
||||
// Create the source
|
||||
*outType = get_read_kernel_type( outFormat );
|
||||
size_t channelSize = get_explicit_type_size( *outType );
|
||||
|
||||
const char* source = get_appropriate_kernel_for_target(gl_target);
|
||||
|
||||
sprintf( kernelSource, source, get_explicit_type_name( *outType ),
|
||||
get_kernel_suffix( outFormat ) );
|
||||
|
||||
programPtr = kernelSource;
|
||||
if( create_single_kernel_helper( context, &program, &kernel, 1,
|
||||
(const char **)&programPtr, "sample_test" ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create a vanilla output buffer
|
||||
streams[ 1 ] = clCreateBuffer( context, CL_MEM_READ_WRITE,
|
||||
channelSize * 4 * width * height * depth, NULL, &error );
|
||||
test_error( error, "Unable to create output buffer" );
|
||||
|
||||
/* Assign streams and execute */
|
||||
clSamplerWrapper sampler = clCreateSampler( context, CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST, &error );
|
||||
test_error( error, "Unable to create sampler" );
|
||||
|
||||
error = clSetKernelArg( kernel, 0, sizeof( streams[ 0 ] ), &streams[ 0 ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
error = clSetKernelArg( kernel, 1, sizeof( sampler ), &sampler );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
error = clSetKernelArg( kernel, 2, sizeof( streams[ 1 ] ), &streams[ 1 ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
|
||||
glFlush();
|
||||
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
|
||||
// The ND range we use is a function of the dimensionality of the image.
|
||||
size_t global_range[3] = { width, height, depth };
|
||||
size_t *local_range = NULL;
|
||||
int ndim = 1;
|
||||
|
||||
switch (get_base_gl_target(gl_target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
ndim = 1;
|
||||
break;
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
case GL_RENDERBUFFER:
|
||||
ndim = 2;
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
ndim = 3;
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 2D and 3D images have a special way to set the local size (legacy).
|
||||
// Otherwise, we let CL select by leaving local_range as NULL.
|
||||
|
||||
if (gl_target == GL_TEXTURE_2D) {
|
||||
local_range = (size_t*)malloc(sizeof(size_t) * ndim);
|
||||
get_max_common_2D_work_group_size( context, kernel, global_range, local_range );
|
||||
|
||||
} else if (gl_target == GL_TEXTURE_3D) {
|
||||
local_range = (size_t*)malloc(sizeof(size_t) * ndim);
|
||||
get_max_common_3D_work_group_size( context, kernel, global_range, local_range );
|
||||
|
||||
}
|
||||
|
||||
error = clEnqueueNDRangeKernel( queue, kernel, ndim, NULL, global_range,
|
||||
local_range, 0, NULL, NULL );
|
||||
test_error( error, "Unable to execute test kernel" );
|
||||
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 0 ],
|
||||
0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
|
||||
// Read results from the CL buffer
|
||||
*outResultBuffer = (void *)( new char[ channelSize * 4 * width * height * depth ] );
|
||||
error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0,
|
||||
channelSize * 4 * width * height * depth, *outResultBuffer, 0, NULL, NULL );
|
||||
test_error( error, "Unable to read output CL buffer!" );
|
||||
|
||||
// free the ranges
|
||||
if (local_range) free(local_range);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_image_read( cl_context context, cl_command_queue queue,
|
||||
GLenum target, GLuint globj, size_t width, size_t height, size_t depth,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL texture or renderbuffer.
|
||||
|
||||
cl_mem image;
|
||||
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_READ_ONLY, globj, &error );
|
||||
} else {
|
||||
image = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
||||
target, 0, globj, &error );
|
||||
}
|
||||
|
||||
if( error != CL_SUCCESS ) {
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
} else {
|
||||
print_error( error, "Unable to create CL image from GL texture" );
|
||||
GLint fmt;
|
||||
glGetTexLevelParameteriv( target, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
||||
log_error( " Supplied GL texture was base format %s and internal "
|
||||
"format %s\n", GetGLBaseFormatName( fmt ), GetGLFormatName( fmt ) );
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_read( context, queue, target, image,
|
||||
width, height, depth, outFormat, outType, outResultBuffer );
|
||||
}
|
||||
|
||||
static int test_image_format_read(
|
||||
cl_context context, cl_command_queue queue,
|
||||
size_t width, size_t height, size_t depth,
|
||||
GLenum target, struct format* fmt, MTdata data)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
// Required for most of the texture-backed cases:
|
||||
glTextureWrapper texture;
|
||||
|
||||
// Required for the special case of TextureBuffer textures:
|
||||
glBufferWrapper glbuf;
|
||||
|
||||
// And these are required for the case of Renderbuffer images:
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
|
||||
void* buffer = NULL;
|
||||
|
||||
// Use the correct texture creation function depending on the target, and
|
||||
// adjust width, height, depth as appropriate so subsequent size calculations
|
||||
// succeed.
|
||||
|
||||
switch (get_base_gl_target(target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
h = 1; d = 1;
|
||||
buffer = CreateGLTexture1D( width, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
h = 1; d = 1;
|
||||
buffer = CreateGLTextureBuffer(width, target, gl_fmt, gl_internal_fmt,
|
||||
gl_type, type, &texture, &glbuf, &error, true, data);
|
||||
break;
|
||||
case GL_RENDERBUFFER:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
buffer = CreateGLRenderbuffer(width, height, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &glFramebuffer, &glRenderbuffer, &error,
|
||||
data, true);
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
d = 1;
|
||||
buffer = CreateGLTexture2D(width, height, target, gl_fmt, gl_internal_fmt,
|
||||
gl_type, type, &texture, &error, true, data);
|
||||
break;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
d = 1;
|
||||
buffer = CreateGLTexture1DArray( width, height, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
buffer = CreateGLTexture2DArray( width, height, depth, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
buffer = CreateGLTexture3D( width, height, depth, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, data, true );
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
BufferOwningPtr<char> inputBuffer(buffer);
|
||||
|
||||
cl_image_format clFormat;
|
||||
ExplicitType actualType;
|
||||
char *outBuffer;
|
||||
|
||||
// Perform the read:
|
||||
|
||||
GLuint globj = texture;
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
globj = glRenderbuffer;
|
||||
}
|
||||
|
||||
error = test_image_read( context, queue, target, globj, w, h, d, &clFormat,
|
||||
&actualType, (void **)&outBuffer );
|
||||
|
||||
if( error != 0 )
|
||||
return error;
|
||||
BufferOwningPtr<char> actualResults(outBuffer);
|
||||
|
||||
log_info( "- Read [%4d x %4d x %4d] : GL Texture : %s : %s : %s => CL Image : %s : %s \n",
|
||||
(int)w, (int)h, (int)d, GetGLFormatName( gl_fmt ), GetGLFormatName( gl_internal_fmt ),
|
||||
GetGLTypeName( gl_type ), GetChannelOrderName( clFormat.image_channel_order ),
|
||||
GetChannelTypeName( clFormat.image_channel_data_type ));
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
// This is necessary because OpenCL might not actually pick an internal format
|
||||
// that actually matches our input format (for example, if it picks a normalized
|
||||
// format, the results will come out as floats instead of going in as ints).
|
||||
|
||||
BufferOwningPtr<char> convertedInputs(convert_to_expected( inputBuffer,
|
||||
w * h * d, type, actualType ));
|
||||
if( convertedInputs == NULL )
|
||||
return -1;
|
||||
|
||||
// Now we validate
|
||||
if( actualType == kFloat ) {
|
||||
return validate_float_results( convertedInputs, actualResults, w, h, d );
|
||||
} else {
|
||||
return validate_integer_results( convertedInputs, actualResults, w, h, d,
|
||||
get_explicit_type_size( actualType ) );
|
||||
}
|
||||
}
|
||||
|
||||
int test_images_read_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes )
|
||||
{
|
||||
int error = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// First, ensure this device supports images.
|
||||
|
||||
if (checkForImageSupport(device)) {
|
||||
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++ ) {
|
||||
|
||||
log_info( "Testing image read 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_read(context, queue,
|
||||
sizes[sidx], sizes[sidx], sizes[sidx],
|
||||
targets[tidx], &formats[fidx], seed) )
|
||||
{
|
||||
// We land here in the event of test failure.
|
||||
|
||||
log_error( "ERROR: Image read 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Note a successful format test, if we passed every size.
|
||||
|
||||
if( sidx == sizeof (sizes) / sizeof( sizes[0] ) ) {
|
||||
log_info( "passed: Image read test for GL format %s : %s : %s : %s\n\n",
|
||||
GetGLTargetName( targets[ tidx ] ),
|
||||
GetGLFormatName( formats[ fidx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fidx ].formattype ),
|
||||
GetGLTypeName( formats[ fidx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "common.h"
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
static const char *kernelpattern_image_read_1d =
|
||||
"__kernel void sample_test( read_only image1d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int offset = get_global_id(0);\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, offset );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_1darray =
|
||||
"__kernel void sample_test( read_only image1d_array_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" results[ tidY * get_image_width( source ) + tidX ] = read_image%s( source, sampler, (int2)( tidX, tidY ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_2d =
|
||||
"__kernel void sample_test( read_only image2d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" results[ tidY * get_image_width( source ) + tidX ] = read_image%s( source, sampler, (int2)( tidX, tidY ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_2darray =
|
||||
"__kernel void sample_test( read_only image2d_array_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" int tidZ = get_global_id(2);\n"
|
||||
" int width = get_image_width( source );\n"
|
||||
" int height = get_image_height( source );\n"
|
||||
" int offset = tidZ * width * height + tidY * width + tidX;\n"
|
||||
"\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, (int4)( tidX, tidY, tidZ, 0 ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char *kernelpattern_image_read_3d =
|
||||
"__kernel void sample_test( read_only image3d_t source, sampler_t sampler, __global %s4 *results )\n"
|
||||
"{\n"
|
||||
" int tidX = get_global_id(0);\n"
|
||||
" int tidY = get_global_id(1);\n"
|
||||
" int tidZ = get_global_id(2);\n"
|
||||
" int width = get_image_width( source );\n"
|
||||
" int height = get_image_height( source );\n"
|
||||
" int offset = tidZ * width * height + tidY * width + tidX;\n"
|
||||
"\n"
|
||||
" results[ offset ] = read_image%s( source, sampler, (int4)( tidX, tidY, tidZ, 0 ) );\n"
|
||||
"}\n";
|
||||
|
||||
static const char* get_appropriate_kernel_for_target(GLenum target) {
|
||||
|
||||
switch (get_base_gl_target(target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
return kernelpattern_image_read_1d;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
return kernelpattern_image_read_1darray;
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
case GL_RENDERBUFFER:
|
||||
return kernelpattern_image_read_2d;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
return kernelpattern_image_read_2darray;
|
||||
case GL_TEXTURE_3D:
|
||||
return kernelpattern_image_read_3d;
|
||||
|
||||
default:
|
||||
log_error("Unsupported texture target (%s); cannot determine "
|
||||
"appropriate kernel.", GetGLTargetName(target));
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
clProgramWrapper program;
|
||||
clKernelWrapper kernel;
|
||||
clMemWrapper streams[ 2 ];
|
||||
|
||||
int error;
|
||||
char kernelSource[1024];
|
||||
char *programPtr;
|
||||
|
||||
// Use the image created from the GL texture.
|
||||
streams[ 0 ] = image;
|
||||
|
||||
// Determine data type and format that CL came up with
|
||||
error = clGetImageInfo( streams[ 0 ], CL_IMAGE_FORMAT, sizeof( cl_image_format ), outFormat, NULL );
|
||||
test_error( error, "Unable to get CL image format" );
|
||||
|
||||
// Create the source
|
||||
*outType = get_read_kernel_type( outFormat );
|
||||
size_t channelSize = get_explicit_type_size( *outType );
|
||||
|
||||
const char* source = get_appropriate_kernel_for_target(gl_target);
|
||||
|
||||
sprintf( kernelSource, source, get_explicit_type_name( *outType ),
|
||||
get_kernel_suffix( outFormat ) );
|
||||
|
||||
programPtr = kernelSource;
|
||||
if( create_single_kernel_helper( context, &program, &kernel, 1,
|
||||
(const char **)&programPtr, "sample_test" ) )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Create a vanilla output buffer
|
||||
streams[ 1 ] = clCreateBuffer( context, CL_MEM_READ_WRITE,
|
||||
channelSize * 4 * width * height * depth, NULL, &error );
|
||||
test_error( error, "Unable to create output buffer" );
|
||||
|
||||
/* Assign streams and execute */
|
||||
clSamplerWrapper sampler = clCreateSampler( context, CL_FALSE, CL_ADDRESS_NONE, CL_FILTER_NEAREST, &error );
|
||||
test_error( error, "Unable to create sampler" );
|
||||
|
||||
error = clSetKernelArg( kernel, 0, sizeof( streams[ 0 ] ), &streams[ 0 ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
error = clSetKernelArg( kernel, 1, sizeof( sampler ), &sampler );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
error = clSetKernelArg( kernel, 2, sizeof( streams[ 1 ] ), &streams[ 1 ] );
|
||||
test_error( error, "Unable to set kernel arguments" );
|
||||
|
||||
glFlush();
|
||||
|
||||
error = (*clEnqueueAcquireGLObjects_ptr)( queue, 1, &streams[ 0 ], 0, NULL, NULL);
|
||||
test_error( error, "Unable to acquire GL obejcts");
|
||||
|
||||
// The ND range we use is a function of the dimensionality of the image.
|
||||
size_t global_range[3] = { width, height, depth };
|
||||
size_t *local_range = NULL;
|
||||
int ndim = 1;
|
||||
|
||||
switch (get_base_gl_target(gl_target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
ndim = 1;
|
||||
break;
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
case GL_RENDERBUFFER:
|
||||
ndim = 2;
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
ndim = 3;
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// 2D and 3D images have a special way to set the local size (legacy).
|
||||
// Otherwise, we let CL select by leaving local_range as NULL.
|
||||
|
||||
if (gl_target == GL_TEXTURE_2D) {
|
||||
local_range = (size_t*)malloc(sizeof(size_t) * ndim);
|
||||
get_max_common_2D_work_group_size( context, kernel, global_range, local_range );
|
||||
|
||||
} else if (gl_target == GL_TEXTURE_3D) {
|
||||
local_range = (size_t*)malloc(sizeof(size_t) * ndim);
|
||||
get_max_common_3D_work_group_size( context, kernel, global_range, local_range );
|
||||
|
||||
}
|
||||
|
||||
error = clEnqueueNDRangeKernel( queue, kernel, ndim, NULL, global_range,
|
||||
local_range, 0, NULL, NULL );
|
||||
test_error( error, "Unable to execute test kernel" );
|
||||
|
||||
error = (*clEnqueueReleaseGLObjects_ptr)( queue, 1, &streams[ 0 ],
|
||||
0, NULL, NULL );
|
||||
test_error(error, "clEnqueueReleaseGLObjects failed");
|
||||
|
||||
// Read results from the CL buffer
|
||||
*outResultBuffer = (void *)( new char[ channelSize * 4 * width * height * depth ] );
|
||||
error = clEnqueueReadBuffer( queue, streams[ 1 ], CL_TRUE, 0,
|
||||
channelSize * 4 * width * height * depth, *outResultBuffer, 0, NULL, NULL );
|
||||
test_error( error, "Unable to read output CL buffer!" );
|
||||
|
||||
// free the ranges
|
||||
if (local_range) free(local_range);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int test_image_read( cl_context context, cl_command_queue queue,
|
||||
GLenum target, GLuint globj, size_t width, size_t height, size_t depth,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL texture or renderbuffer.
|
||||
|
||||
cl_mem image;
|
||||
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_READ_ONLY, globj, &error );
|
||||
} else {
|
||||
image = (*clCreateFromGLTexture_ptr)( context, CL_MEM_READ_ONLY,
|
||||
target, 0, globj, &error );
|
||||
}
|
||||
|
||||
if( error != CL_SUCCESS ) {
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
} else {
|
||||
print_error( error, "Unable to create CL image from GL texture" );
|
||||
GLint fmt;
|
||||
glGetTexLevelParameteriv( target, 0, GL_TEXTURE_INTERNAL_FORMAT, &fmt );
|
||||
log_error( " Supplied GL texture was base format %s and internal "
|
||||
"format %s\n", GetGLBaseFormatName( fmt ), GetGLFormatName( fmt ) );
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_read( context, queue, target, image,
|
||||
width, height, depth, outFormat, outType, outResultBuffer );
|
||||
}
|
||||
|
||||
static int test_image_format_read(
|
||||
cl_context context, cl_command_queue queue,
|
||||
size_t width, size_t height, size_t depth,
|
||||
GLenum target, struct format* fmt, MTdata data)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
// Required for most of the texture-backed cases:
|
||||
glTextureWrapper texture;
|
||||
|
||||
// Required for the special case of TextureBuffer textures:
|
||||
glBufferWrapper glbuf;
|
||||
|
||||
// And these are required for the case of Renderbuffer images:
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
|
||||
void* buffer = NULL;
|
||||
|
||||
// Use the correct texture creation function depending on the target, and
|
||||
// adjust width, height, depth as appropriate so subsequent size calculations
|
||||
// succeed.
|
||||
|
||||
switch (get_base_gl_target(target)) {
|
||||
case GL_TEXTURE_1D:
|
||||
h = 1; d = 1;
|
||||
buffer = CreateGLTexture1D( width, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_BUFFER:
|
||||
h = 1; d = 1;
|
||||
buffer = CreateGLTextureBuffer(width, target, gl_fmt, gl_internal_fmt,
|
||||
gl_type, type, &texture, &glbuf, &error, true, data);
|
||||
break;
|
||||
case GL_RENDERBUFFER:
|
||||
case GL_COLOR_ATTACHMENT0:
|
||||
buffer = CreateGLRenderbuffer(width, height, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &glFramebuffer, &glRenderbuffer, &error,
|
||||
data, true);
|
||||
break;
|
||||
case GL_TEXTURE_2D:
|
||||
case GL_TEXTURE_RECTANGLE_EXT:
|
||||
d = 1;
|
||||
buffer = CreateGLTexture2D(width, height, target, gl_fmt, gl_internal_fmt,
|
||||
gl_type, type, &texture, &error, true, data);
|
||||
break;
|
||||
case GL_TEXTURE_1D_ARRAY:
|
||||
d = 1;
|
||||
buffer = CreateGLTexture1DArray( width, height, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_2D_ARRAY:
|
||||
buffer = CreateGLTexture2DArray( width, height, depth, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, true, data );
|
||||
break;
|
||||
case GL_TEXTURE_3D:
|
||||
buffer = CreateGLTexture3D( width, height, depth, target, gl_fmt,
|
||||
gl_internal_fmt, gl_type, type, &texture, &error, data, true );
|
||||
break;
|
||||
default:
|
||||
log_error("Unsupported texture target.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
BufferOwningPtr<char> inputBuffer(buffer);
|
||||
|
||||
cl_image_format clFormat;
|
||||
ExplicitType actualType;
|
||||
char *outBuffer;
|
||||
|
||||
// Perform the read:
|
||||
|
||||
GLuint globj = texture;
|
||||
if (target == GL_RENDERBUFFER || target == GL_COLOR_ATTACHMENT0) {
|
||||
globj = glRenderbuffer;
|
||||
}
|
||||
|
||||
error = test_image_read( context, queue, target, globj, w, h, d, &clFormat,
|
||||
&actualType, (void **)&outBuffer );
|
||||
|
||||
if( error != 0 )
|
||||
return error;
|
||||
BufferOwningPtr<char> actualResults(outBuffer);
|
||||
|
||||
log_info( "- Read [%4d x %4d x %4d] : GL Texture : %s : %s : %s => CL Image : %s : %s \n",
|
||||
(int)w, (int)h, (int)d, GetGLFormatName( gl_fmt ), GetGLFormatName( gl_internal_fmt ),
|
||||
GetGLTypeName( gl_type ), GetChannelOrderName( clFormat.image_channel_order ),
|
||||
GetChannelTypeName( clFormat.image_channel_data_type ));
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
// This is necessary because OpenCL might not actually pick an internal format
|
||||
// that actually matches our input format (for example, if it picks a normalized
|
||||
// format, the results will come out as floats instead of going in as ints).
|
||||
|
||||
BufferOwningPtr<char> convertedInputs(convert_to_expected( inputBuffer,
|
||||
w * h * d, type, actualType ));
|
||||
if( convertedInputs == NULL )
|
||||
return -1;
|
||||
|
||||
// Now we validate
|
||||
if( actualType == kFloat ) {
|
||||
return validate_float_results( convertedInputs, actualResults, w, h, d );
|
||||
} else {
|
||||
return validate_integer_results( convertedInputs, actualResults, w, h, d,
|
||||
get_explicit_type_size( actualType ) );
|
||||
}
|
||||
}
|
||||
|
||||
int test_images_read_common( cl_device_id device, cl_context context,
|
||||
cl_command_queue queue, struct format* formats, size_t nformats,
|
||||
GLenum *targets, size_t ntargets, size_t *sizes, size_t nsizes )
|
||||
{
|
||||
int error = 0;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// First, ensure this device supports images.
|
||||
|
||||
if (checkForImageSupport(device)) {
|
||||
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++ ) {
|
||||
|
||||
log_info( "Testing image read 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_read(context, queue,
|
||||
sizes[sidx], sizes[sidx], sizes[sidx],
|
||||
targets[tidx], &formats[fidx], seed) )
|
||||
{
|
||||
// We land here in the event of test failure.
|
||||
|
||||
log_error( "ERROR: Image read 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;
|
||||
}
|
||||
}
|
||||
|
||||
// Note a successful format test, if we passed every size.
|
||||
|
||||
if( sidx == sizeof (sizes) / sizeof( sizes[0] ) ) {
|
||||
log_info( "passed: Image read test for GL format %s : %s : %s : %s\n\n",
|
||||
GetGLTargetName( targets[ tidx ] ),
|
||||
GetGLFormatName( formats[ fidx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fidx ].formattype ),
|
||||
GetGLTypeName( formats[ fidx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,479 +1,479 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
GLboolean
|
||||
gluCheckExtension(const GLubyte *extension, const GLubyte *extensions)
|
||||
{
|
||||
const GLubyte *start;
|
||||
GLubyte *where, *terminator;
|
||||
|
||||
/* Extension names should not have spaces. */
|
||||
where = (GLubyte *) strchr((const char*)extension, ' ');
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
// This is defined in the write common code:
|
||||
extern int test_cl_image_write( cl_context context, cl_command_queue queue,
|
||||
GLenum target, cl_mem clImage, size_t imageWidth, size_t imageHeight,
|
||||
size_t imageDepth, 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,
|
||||
GLenum gl_target, cl_mem image, size_t width, size_t height, size_t depth,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer );
|
||||
|
||||
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,
|
||||
size_t imageWidth, size_t imageHeight, cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL renderbuffer
|
||||
cl_mem image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_READ_ONLY, glRenderbuffer, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_read( context, queue, glTarget, image, imageWidth,
|
||||
imageHeight, 1, outFormat, outType, outResultBuffer );
|
||||
}
|
||||
|
||||
int test_renderbuffer_read_image( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL renderbuffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
void *tmp = CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true );
|
||||
BufferOwningPtr<char> inputBuffer(tmp);
|
||||
if( error != 0 )
|
||||
{
|
||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
||||
{
|
||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Run and get the results
|
||||
cl_image_format clFormat;
|
||||
ExplicitType actualType;
|
||||
char *outBuffer;
|
||||
error = test_attach_renderbuffer_read_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &actualType, (void **)&outBuffer );
|
||||
if( error != 0 )
|
||||
return error;
|
||||
BufferOwningPtr<char> actualResults(outBuffer);
|
||||
|
||||
log_info( "- Read [%4d x %4d] : GL renderbuffer : %s : %s : %s => CL Image : %s : %s \n", width, height,
|
||||
GetGLFormatName( format ), GetGLFormatName( internalFormat ), GetGLTypeName( glType),
|
||||
GetChannelOrderName( clFormat.image_channel_order ), GetChannelTypeName( clFormat.image_channel_data_type ));
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start read GL data -- \n");
|
||||
DumpGLBuffer(glType, width, height, actualResults);
|
||||
log_info("- end read GL data -- \n");
|
||||
#endif
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
BufferOwningPtr<char> convertedInput(convert_to_expected( inputBuffer, width * height, type, actualType ));
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start input data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, convertedInput);
|
||||
log_info("- end input data -- \n");
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start converted data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, actualResults);
|
||||
log_info("- end converted data -- \n");
|
||||
#endif
|
||||
|
||||
// Now we validate
|
||||
int valid = 0;
|
||||
if(convertedInput) {
|
||||
if( actualType == kFloat )
|
||||
valid = validate_float_results( convertedInput, actualResults, width, height );
|
||||
else
|
||||
valid = validate_integer_results( convertedInput, actualResults, width, height, get_explicit_type_size( actualType ) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
int test_renderbuffer_read( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ 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_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
|
||||
// Renderbuffers with integer formats do not seem to work reliably across
|
||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
||||
|
||||
#ifdef TEST_INTEGER_FORMATS
|
||||
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
#endif
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, attIdx;
|
||||
int error = 0;
|
||||
#ifdef DEBUG
|
||||
size_t iter = 1;
|
||||
#else
|
||||
size_t iter = 6;
|
||||
#endif
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
log_info( "Testing renderbuffer read for %s : %s : %s : %s\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = random_in_range( 16, 512, seed );
|
||||
GLsizei height = random_in_range( 16, 512, seed );
|
||||
#ifdef DEBUG
|
||||
width = height = 4;
|
||||
#endif
|
||||
|
||||
if( test_renderbuffer_read_image( context, queue, width, height,
|
||||
attachments[ attIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer read test failed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer read test passed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -------------------- Write tests -------------------------
|
||||
|
||||
int test_attach_renderbuffer_write_to_image( 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;
|
||||
|
||||
// Create a CL image from the supplied GL renderbuffer
|
||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_WRITE_ONLY, glRenderbuffer, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_write( context, queue, glTarget, image, imageWidth,
|
||||
imageHeight, 1, outFormat, outType, outSourceBuffer, d, supports_half );
|
||||
}
|
||||
|
||||
int test_renderbuffer_image_write( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL renderbuffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, false );
|
||||
if( error != 0 )
|
||||
{
|
||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
||||
{
|
||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Run and get the results
|
||||
cl_image_format clFormat;
|
||||
ExplicitType sourceType;
|
||||
ExplicitType validationType;
|
||||
void *outSourceBuffer;
|
||||
|
||||
bool supports_half = false;
|
||||
error = supportsHalf(context, &supports_half);
|
||||
if( error != 0 )
|
||||
return error;
|
||||
|
||||
error = test_attach_renderbuffer_write_to_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &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( sourceType == kHalf )
|
||||
validationType = kFloat;
|
||||
else
|
||||
validationType = sourceType;
|
||||
|
||||
BufferOwningPtr<char> validationSource( convert_to_expected( outSourceBuffer, width * height, sourceType, validationType ) );
|
||||
|
||||
log_info( "- Write [%4d x %4d] : GL Renderbuffer : %s : %s : %s => CL Image : %s : %s \n", 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
|
||||
BufferOwningPtr<char> resultData( ReadGLRenderbuffer( glFramebuffer, glRenderbuffer, attachment, format, internalFormat, glType, type, width, height ) );
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start result data -- \n");
|
||||
DumpGLBuffer(glType, width, height, resultData);
|
||||
log_info("- end result data -- \n");
|
||||
#endif
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
BufferOwningPtr<char> convertedData( convert_to_expected( resultData, width * height, type, validationType ) );
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start input data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, validationSource);
|
||||
log_info("- end input data -- \n");
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start converted data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, convertedData);
|
||||
log_info("- end converted data -- \n");
|
||||
#endif
|
||||
|
||||
// Now we validate
|
||||
int valid = 0;
|
||||
if(convertedData) {
|
||||
if( sourceType == kFloat || sourceType == kHalf )
|
||||
valid = validate_float_results( validationSource, convertedData, width, height );
|
||||
else
|
||||
valid = validate_integer_results( validationSource, convertedData, width, height, get_explicit_type_size( type ) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
int test_renderbuffer_write( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ 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_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
|
||||
// Renderbuffers with integer formats do not seem to work reliably across
|
||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
||||
|
||||
#ifdef TEST_INTEGER_FORMATS
|
||||
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
#endif
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, attIdx;
|
||||
int error = 0;
|
||||
size_t iter = 6;
|
||||
#ifdef DEBUG
|
||||
iter = 1;
|
||||
#endif
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
||||
{
|
||||
log_info( "Testing Renderbuffer write test for %s : %s : %s : %s\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
size_t i;
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = random_in_range( 16, 512, seed );
|
||||
GLsizei height = random_in_range( 16, 512, seed );
|
||||
#ifdef DEBUG
|
||||
width = height = 4;
|
||||
#endif
|
||||
|
||||
if( test_renderbuffer_image_write( context, queue, width, height,
|
||||
attachments[ attIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer write test failed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer write test passed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
GLboolean
|
||||
gluCheckExtension(const GLubyte *extension, const GLubyte *extensions)
|
||||
{
|
||||
const GLubyte *start;
|
||||
GLubyte *where, *terminator;
|
||||
|
||||
/* Extension names should not have spaces. */
|
||||
where = (GLubyte *) strchr((const char*)extension, ' ');
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
extern "C" { extern cl_uint gRandomSeed; };
|
||||
|
||||
// This is defined in the write common code:
|
||||
extern int test_cl_image_write( cl_context context, cl_command_queue queue,
|
||||
GLenum target, cl_mem clImage, size_t imageWidth, size_t imageHeight,
|
||||
size_t imageDepth, 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,
|
||||
GLenum gl_target, cl_mem image, size_t width, size_t height, size_t depth,
|
||||
cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer );
|
||||
|
||||
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,
|
||||
size_t imageWidth, size_t imageHeight, cl_image_format *outFormat, ExplicitType *outType, void **outResultBuffer )
|
||||
{
|
||||
int error;
|
||||
|
||||
// Create a CL image from the supplied GL renderbuffer
|
||||
cl_mem image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_READ_ONLY, glRenderbuffer, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_read( context, queue, glTarget, image, imageWidth,
|
||||
imageHeight, 1, outFormat, outType, outResultBuffer );
|
||||
}
|
||||
|
||||
int test_renderbuffer_read_image( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL renderbuffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
void *tmp = CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true );
|
||||
BufferOwningPtr<char> inputBuffer(tmp);
|
||||
if( error != 0 )
|
||||
{
|
||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
||||
{
|
||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Run and get the results
|
||||
cl_image_format clFormat;
|
||||
ExplicitType actualType;
|
||||
char *outBuffer;
|
||||
error = test_attach_renderbuffer_read_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &actualType, (void **)&outBuffer );
|
||||
if( error != 0 )
|
||||
return error;
|
||||
BufferOwningPtr<char> actualResults(outBuffer);
|
||||
|
||||
log_info( "- Read [%4d x %4d] : GL renderbuffer : %s : %s : %s => CL Image : %s : %s \n", width, height,
|
||||
GetGLFormatName( format ), GetGLFormatName( internalFormat ), GetGLTypeName( glType),
|
||||
GetChannelOrderName( clFormat.image_channel_order ), GetChannelTypeName( clFormat.image_channel_data_type ));
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start read GL data -- \n");
|
||||
DumpGLBuffer(glType, width, height, actualResults);
|
||||
log_info("- end read GL data -- \n");
|
||||
#endif
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
BufferOwningPtr<char> convertedInput(convert_to_expected( inputBuffer, width * height, type, actualType ));
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start input data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, convertedInput);
|
||||
log_info("- end input data -- \n");
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start converted data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(actualType), width, height, actualResults);
|
||||
log_info("- end converted data -- \n");
|
||||
#endif
|
||||
|
||||
// Now we validate
|
||||
int valid = 0;
|
||||
if(convertedInput) {
|
||||
if( actualType == kFloat )
|
||||
valid = validate_float_results( convertedInput, actualResults, width, height );
|
||||
else
|
||||
valid = validate_integer_results( convertedInput, actualResults, width, height, get_explicit_type_size( actualType ) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
int test_renderbuffer_read( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ 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_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
|
||||
// Renderbuffers with integer formats do not seem to work reliably across
|
||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
||||
|
||||
#ifdef TEST_INTEGER_FORMATS
|
||||
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
#endif
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, attIdx;
|
||||
int error = 0;
|
||||
#ifdef DEBUG
|
||||
size_t iter = 1;
|
||||
#else
|
||||
size_t iter = 6;
|
||||
#endif
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
||||
{
|
||||
size_t i;
|
||||
|
||||
log_info( "Testing renderbuffer read for %s : %s : %s : %s\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = random_in_range( 16, 512, seed );
|
||||
GLsizei height = random_in_range( 16, 512, seed );
|
||||
#ifdef DEBUG
|
||||
width = height = 4;
|
||||
#endif
|
||||
|
||||
if( test_renderbuffer_read_image( context, queue, width, height,
|
||||
attachments[ attIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer read test failed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer read test passed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -------------------- Write tests -------------------------
|
||||
|
||||
int test_attach_renderbuffer_write_to_image( 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;
|
||||
|
||||
// Create a CL image from the supplied GL renderbuffer
|
||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)( context, CL_MEM_WRITE_ONLY, glRenderbuffer, &error );
|
||||
if( error != CL_SUCCESS )
|
||||
{
|
||||
print_error( error, "Unable to create CL image from GL renderbuffer" );
|
||||
return error;
|
||||
}
|
||||
|
||||
return test_cl_image_write( context, queue, glTarget, image, imageWidth,
|
||||
imageHeight, 1, outFormat, outType, outSourceBuffer, d, supports_half );
|
||||
}
|
||||
|
||||
int test_renderbuffer_image_write( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL renderbuffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, false );
|
||||
if( error != 0 )
|
||||
{
|
||||
if ((format == GL_RGBA_INTEGER_EXT) && (!CheckGLIntegerExtensionSupport()))
|
||||
{
|
||||
log_info("OpenGL version does not support GL_RGBA_INTEGER_EXT. Skipping test.\n");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
// Run and get the results
|
||||
cl_image_format clFormat;
|
||||
ExplicitType sourceType;
|
||||
ExplicitType validationType;
|
||||
void *outSourceBuffer;
|
||||
|
||||
bool supports_half = false;
|
||||
error = supportsHalf(context, &supports_half);
|
||||
if( error != 0 )
|
||||
return error;
|
||||
|
||||
error = test_attach_renderbuffer_write_to_image( context, queue, attachment, glRenderbuffer, width, height, &clFormat, &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( sourceType == kHalf )
|
||||
validationType = kFloat;
|
||||
else
|
||||
validationType = sourceType;
|
||||
|
||||
BufferOwningPtr<char> validationSource( convert_to_expected( outSourceBuffer, width * height, sourceType, validationType ) );
|
||||
|
||||
log_info( "- Write [%4d x %4d] : GL Renderbuffer : %s : %s : %s => CL Image : %s : %s \n", 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
|
||||
BufferOwningPtr<char> resultData( ReadGLRenderbuffer( glFramebuffer, glRenderbuffer, attachment, format, internalFormat, glType, type, width, height ) );
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start result data -- \n");
|
||||
DumpGLBuffer(glType, width, height, resultData);
|
||||
log_info("- end result data -- \n");
|
||||
#endif
|
||||
|
||||
// We have to convert our input buffer to the returned type, so we can validate.
|
||||
BufferOwningPtr<char> convertedData( convert_to_expected( resultData, width * height, type, validationType ) );
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start input data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, validationSource);
|
||||
log_info("- end input data -- \n");
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
log_info("- start converted data -- \n");
|
||||
DumpGLBuffer(GetGLTypeForExplicitType(validationType), width, height, convertedData);
|
||||
log_info("- end converted data -- \n");
|
||||
#endif
|
||||
|
||||
// Now we validate
|
||||
int valid = 0;
|
||||
if(convertedData) {
|
||||
if( sourceType == kFloat || sourceType == kHalf )
|
||||
valid = validate_float_results( validationSource, convertedData, width, height );
|
||||
else
|
||||
valid = validate_integer_results( validationSource, convertedData, width, height, get_explicit_type_size( type ) );
|
||||
}
|
||||
|
||||
return valid;
|
||||
}
|
||||
|
||||
int test_renderbuffer_write( cl_device_id device, cl_context context, cl_command_queue queue, int numElements )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ 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_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
|
||||
// Renderbuffers with integer formats do not seem to work reliably across
|
||||
// platforms/implementations. Disabling this in version 1.0 of CL conformance tests.
|
||||
|
||||
#ifdef TEST_INTEGER_FORMATS
|
||||
|
||||
{ GL_RGBA8I_EXT, GL_RGBA_INTEGER_EXT, GL_BYTE, kChar },
|
||||
{ GL_RGBA16I_EXT, GL_RGBA_INTEGER_EXT, GL_SHORT, kShort },
|
||||
{ GL_RGBA32I_EXT, GL_RGBA_INTEGER_EXT, GL_INT, kInt },
|
||||
{ GL_RGBA8UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32UI_EXT, GL_RGBA_INTEGER_EXT, GL_UNSIGNED_INT, kUInt },
|
||||
#endif
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, attIdx;
|
||||
int error = 0;
|
||||
size_t iter = 6;
|
||||
#ifdef DEBUG
|
||||
iter = 1;
|
||||
#endif
|
||||
RandomSeed seed( gRandomSeed );
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( attIdx = 0; attIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); attIdx++ )
|
||||
{
|
||||
log_info( "Testing Renderbuffer write test for %s : %s : %s : %s\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
size_t i;
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = random_in_range( 16, 512, seed );
|
||||
GLsizei height = random_in_range( 16, 512, seed );
|
||||
#ifdef DEBUG
|
||||
width = height = 4;
|
||||
#endif
|
||||
|
||||
if( test_renderbuffer_image_write( context, queue, width, height,
|
||||
attachments[ attIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer write test failed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer write test passed for %s : %s : %s : %s\n\n",
|
||||
GetGLAttachmentName( attachments[ attIdx ] ),
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" {extern cl_uint gRandomSeed;};
|
||||
|
||||
static int test_renderbuffer_object_info( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL render buffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
BufferOwningPtr<char> inputBuffer(CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true ));
|
||||
if( error != 0 )
|
||||
return error;
|
||||
|
||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)(context, CL_MEM_READ_ONLY, glRenderbuffer, &error);
|
||||
test_error(error, "clCreateFromGLRenderbuffer failed");
|
||||
|
||||
log_info( "- Given a GL format of %s, input type was %s, size was %d x %d\n",
|
||||
GetGLFormatName( internalFormat ),
|
||||
get_explicit_type_name( type ), (int)width, (int)height );
|
||||
|
||||
// Verify the expected information here.
|
||||
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 )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, tgtIdx;
|
||||
int error = 0;
|
||||
size_t iter = 6;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( tgtIdx = 0; tgtIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); tgtIdx++ )
|
||||
{
|
||||
log_info( "Testing Renderbuffer object info for %s : %s : %s\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
size_t i;
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = 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,
|
||||
attachments[ tgtIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer write test failed for GL format %s : %s\n\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer write test passed for GL format %s : %s\n\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
//
|
||||
// Copyright (c) 2017 The Khronos Group Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
#include "testBase.h"
|
||||
#if defined( __APPLE__ )
|
||||
#include <OpenGL/glu.h>
|
||||
#else
|
||||
#include <GL/glu.h>
|
||||
#include <CL/cl_gl.h>
|
||||
#endif
|
||||
|
||||
extern "C" {extern cl_uint gRandomSeed;};
|
||||
|
||||
static int test_renderbuffer_object_info( cl_context context, cl_command_queue queue,
|
||||
GLsizei width, GLsizei height, GLenum attachment,
|
||||
GLenum format, GLenum internalFormat,
|
||||
GLenum glType, ExplicitType type, MTdata d )
|
||||
{
|
||||
int error;
|
||||
|
||||
if( type == kHalf )
|
||||
if( DetectFloatToHalfRoundingMode(queue) )
|
||||
return 1;
|
||||
|
||||
// Create the GL render buffer
|
||||
glFramebufferWrapper glFramebuffer;
|
||||
glRenderbufferWrapper glRenderbuffer;
|
||||
BufferOwningPtr<char> inputBuffer(CreateGLRenderbuffer( width, height, attachment, format, internalFormat, glType, type, &glFramebuffer, &glRenderbuffer, &error, d, true ));
|
||||
if( error != 0 )
|
||||
return error;
|
||||
|
||||
clMemWrapper image = (*clCreateFromGLRenderbuffer_ptr)(context, CL_MEM_READ_ONLY, glRenderbuffer, &error);
|
||||
test_error(error, "clCreateFromGLRenderbuffer failed");
|
||||
|
||||
log_info( "- Given a GL format of %s, input type was %s, size was %d x %d\n",
|
||||
GetGLFormatName( internalFormat ),
|
||||
get_explicit_type_name( type ), (int)width, (int)height );
|
||||
|
||||
// Verify the expected information here.
|
||||
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 )
|
||||
{
|
||||
GLenum attachments[] = { GL_COLOR_ATTACHMENT0_EXT };
|
||||
|
||||
struct {
|
||||
GLenum internal;
|
||||
GLenum format;
|
||||
GLenum datatype;
|
||||
ExplicitType type;
|
||||
|
||||
} formats[] = {
|
||||
{ GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, kUChar },
|
||||
{ GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, kUShort },
|
||||
{ GL_RGBA32F_ARB, GL_RGBA, GL_FLOAT, kFloat },
|
||||
{ GL_RGBA16F_ARB, GL_RGBA, GL_HALF_FLOAT, kHalf }
|
||||
};
|
||||
|
||||
size_t fmtIdx, tgtIdx;
|
||||
int error = 0;
|
||||
size_t iter = 6;
|
||||
RandomSeed seed(gRandomSeed);
|
||||
|
||||
// Check if images are supported
|
||||
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" );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 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( tgtIdx = 0; tgtIdx < sizeof( attachments ) / sizeof( attachments[ 0 ] ); tgtIdx++ )
|
||||
{
|
||||
log_info( "Testing Renderbuffer object info for %s : %s : %s\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLBaseFormatName( formats[ fmtIdx ].format ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
size_t i;
|
||||
for( i = 0; i < iter; i++ )
|
||||
{
|
||||
GLsizei width = 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,
|
||||
attachments[ tgtIdx ],
|
||||
formats[ fmtIdx ].format,
|
||||
formats[ fmtIdx ].internal,
|
||||
formats[ fmtIdx ].datatype,
|
||||
formats[ fmtIdx ].type, seed ) )
|
||||
{
|
||||
log_error( "ERROR: Renderbuffer write test failed for GL format %s : %s\n\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
error++;
|
||||
break; // Skip other sizes for this combination
|
||||
}
|
||||
}
|
||||
if( i == iter )
|
||||
{
|
||||
log_info( "passed: Renderbuffer write test passed for GL format %s : %s\n\n",
|
||||
GetGLFormatName( formats[ fmtIdx ].internal ),
|
||||
GetGLTypeName( formats[ fmtIdx ].datatype ) );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user