Remove GL compatibility common code

It is completely unused.

Signed-off-by: Kevin Petit <kevin.petit@arm.com>
This commit is contained in:
Kevin Petit
2019-08-07 11:26:12 +01:00
committed by Kévin Petit
parent 42cc707131
commit fba5b654e8
4 changed files with 0 additions and 2161 deletions

View File

@@ -1,52 +0,0 @@
//
// 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 _gl_headers_h
#define _gl_headers_h
#if defined( __APPLE__ )
#include <OpenGL/OpenGL.h>
#if defined(CGL_VERSION_1_3)
#include <OpenGL/gl3.h>
#include <OpenGL/gl3ext.h>
#else
#include <OpenGL/gl.h>
#include <OpenGL/glext.h>
#endif
#include <GLUT/glut.h>
#else
#ifdef _WIN32
#include <windows.h>
#endif
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glext.h>
#ifdef _WIN32
#include <GL/glut.h>
#else
#include <GL/freeglut.h>
#endif
#endif
#ifdef _WIN32
GLboolean gluCheckExtension(const GLubyte *extName, const GLubyte *extString);
// No glutGetProcAddress in the standard glut v3.7.
#define glutGetProcAddress(procName) wglGetProcAddress(procName)
#endif
#endif // __gl_headers_h

File diff suppressed because it is too large Load Diff

View File

@@ -1,283 +0,0 @@
//
// 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 _helpers_h
#define _helpers_h
#include "../harness/compat.h"
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#if !defined (__APPLE__)
#include <CL/cl.h>
#include "gl_headers.h"
#include <CL/cl_gl.h>
#else
#include "gl_headers.h"
#endif
#include "harness/errorHelpers.h"
#include "harness/kernelHelpers.h"
#include "harness/threadTesting.h"
#include "harness/typeWrappers.h"
#include "harness/conversions.h"
#include "harness/mt19937.h"
typedef cl_mem
(CL_API_CALL *clCreateFromGLBuffer_fn)(cl_context context,
cl_mem_flags flags,
GLuint bufobj,
int * errcode_ret);
typedef cl_mem
(CL_API_CALL *clCreateFromGLTexture_fn)(cl_context context ,
cl_mem_flags flags ,
GLenum target ,
GLint miplevel ,
GLuint texture ,
cl_int * errcode_ret) ;
typedef cl_mem
(CL_API_CALL *clCreateFromGLTexture2D_fn)(cl_context context ,
cl_mem_flags flags ,
GLenum target ,
GLint miplevel ,
GLuint texture ,
cl_int * errcode_ret) ;
typedef cl_mem
(CL_API_CALL *clCreateFromGLTexture3D_fn)(cl_context context ,
cl_mem_flags flags ,
GLenum target ,
GLint miplevel ,
GLuint texture ,
cl_int * errcode_ret) ;
typedef cl_mem
(CL_API_CALL *clCreateFromGLRenderbuffer_fn)(cl_context context ,
cl_mem_flags flags ,
GLuint renderbuffer ,
cl_int * errcode_ret) ;
typedef cl_int
(CL_API_CALL *clGetGLObjectInfo_fn)(cl_mem memobj ,
cl_gl_object_type * gl_object_type ,
GLuint * gl_object_name) ;
typedef cl_int
(CL_API_CALL *clGetGLTextureInfo_fn)(cl_mem memobj ,
cl_gl_texture_info param_name ,
size_t param_value_size ,
void * param_value ,
size_t * param_value_size_ret) ;
typedef cl_int
(CL_API_CALL *clEnqueueAcquireGLObjects_fn)(cl_command_queue command_queue ,
cl_uint num_objects ,
const cl_mem * mem_objects ,
cl_uint num_events_in_wait_list ,
const cl_event * event_wait_list ,
cl_event * event) ;
typedef cl_int
(CL_API_CALL *clEnqueueReleaseGLObjects_fn)(cl_command_queue command_queue ,
cl_uint num_objects ,
const cl_mem * mem_objects ,
cl_uint num_events_in_wait_list ,
const cl_event * event_wait_list ,
cl_event * event) ;
extern clCreateFromGLBuffer_fn clCreateFromGLBuffer_ptr;
extern clCreateFromGLTexture_fn clCreateFromGLTexture_ptr;
extern clCreateFromGLTexture2D_fn clCreateFromGLTexture2D_ptr;
extern clCreateFromGLTexture3D_fn clCreateFromGLTexture3D_ptr;
extern clCreateFromGLRenderbuffer_fn clCreateFromGLRenderbuffer_ptr;
extern clGetGLObjectInfo_fn clGetGLObjectInfo_ptr;
extern clGetGLTextureInfo_fn clGetGLTextureInfo_ptr;
extern clEnqueueAcquireGLObjects_fn clEnqueueAcquireGLObjects_ptr;
extern clEnqueueReleaseGLObjects_fn clEnqueueReleaseGLObjects_ptr;
class glBufferWrapper
{
public:
glBufferWrapper() { mBuffer = 0; }
glBufferWrapper( GLuint b ) { mBuffer = b; }
~glBufferWrapper() { if( mBuffer != 0 ) glDeleteBuffers( 1, &mBuffer ); }
glBufferWrapper & operator=( const GLuint &rhs ) { mBuffer = rhs; return *this; }
operator GLuint() { return mBuffer; }
operator GLuint *() { return &mBuffer; }
GLuint * operator&() { return &mBuffer; }
bool operator==( GLuint rhs ) { return mBuffer == rhs; }
protected:
GLuint mBuffer;
};
class glTextureWrapper
{
public:
glTextureWrapper() { mHandle = 0; }
glTextureWrapper( GLuint b ) { mHandle = b; }
~glTextureWrapper() {
if( mHandle != 0 ) glDeleteTextures( 1, &mHandle );
}
glTextureWrapper & operator=( const GLuint &rhs ) { mHandle = rhs; return *this; }
operator GLuint() { return mHandle; }
operator GLuint *() { return &mHandle; }
GLuint * operator&() { return &mHandle; }
bool operator==( GLuint rhs ) { return mHandle == rhs; }
protected:
// The texture handle.
GLuint mHandle;
};
class glRenderbufferWrapper
{
public:
glRenderbufferWrapper() { mBuffer = 0; }
glRenderbufferWrapper( GLuint b ) { mBuffer = b; }
~glRenderbufferWrapper() { if( mBuffer != 0 ) glDeleteRenderbuffersEXT( 1, &mBuffer ); }
glRenderbufferWrapper & operator=( const GLuint &rhs ) { mBuffer = rhs; return *this; }
operator GLuint() { return mBuffer; }
operator GLuint *() { return &mBuffer; }
GLuint * operator&() { return &mBuffer; }
bool operator==( GLuint rhs ) { return mBuffer == rhs; }
protected:
GLuint mBuffer;
};
class glFramebufferWrapper
{
public:
glFramebufferWrapper() { mBuffer = 0; }
glFramebufferWrapper( GLuint b ) { mBuffer = b; }
~glFramebufferWrapper() { if( mBuffer != 0 ) glDeleteFramebuffersEXT( 1, &mBuffer ); }
glFramebufferWrapper & operator=( const GLuint &rhs ) { mBuffer = rhs; return *this; }
operator GLuint() { return mBuffer; }
operator GLuint *() { return &mBuffer; }
GLuint * operator&() { return &mBuffer; }
bool operator==( GLuint rhs ) { return mBuffer == rhs; }
protected:
GLuint mBuffer;
};
// Helper functions (defined in helpers.cpp)
extern void * CreateGLTexture1DArray( size_t width, size_t length,
GLenum target, GLenum glFormat, GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTextureID, int *outError,
bool allocateMem, MTdata d);
extern void * CreateGLTexture2DArray( size_t width, size_t height, size_t length,
GLenum target, GLenum glFormat, GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTextureID, int *outError,
bool allocateMem, MTdata d);
extern void * CreateGLTextureBuffer( size_t width,
GLenum target, GLenum glFormat, GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTex, GLuint *outBuf, int *outError,
bool allocateMem, MTdata d);
extern void * CreateGLTexture1D(size_t width,
GLenum target, GLenum glFormat,
GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTextureID,
int *outError, bool allocateMem, MTdata d );
extern void * CreateGLTexture2D( size_t width, size_t height,
GLenum target, GLenum glFormat,
GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTextureID,
int *outError, bool allocateMem, MTdata d );
extern void * CreateGLTexture3D( size_t width, size_t height, size_t depth,
GLenum target, GLenum glFormat,
GLenum internalFormat, GLenum glType,
ExplicitType type, GLuint *outTextureID,
int *outError, MTdata d, bool allocateMem = true );
extern void * ReadGLTexture( GLenum glTarget, GLuint glTexture, GLuint glBuf, GLint width,
GLenum glFormat, GLenum glInternalFormat,
GLenum glType, ExplicitType typeToReadAs,
size_t outWidth, size_t outHeight );
extern int CreateGLRenderbufferRaw( GLsizei width, GLsizei height,
GLenum target, GLenum glFormat,
GLenum internalFormat, GLenum glType,
GLuint *outFramebuffer,
GLuint *outRenderbuffer );
extern void * CreateGLRenderbuffer( GLsizei width, GLsizei height,
GLenum target, GLenum glFormat,
GLenum internalFormat, GLenum glType,
ExplicitType type,
GLuint *outFramebuffer,
GLuint *outRenderbuffer,
int *outError, MTdata d, bool allocateMem );
extern void * ReadGLRenderbuffer( GLuint glFramebuffer, GLuint glRenderbuffer,
GLenum attachment, GLenum glFormat,
GLenum glInternalFormat, GLenum glType,
ExplicitType typeToReadAs,
size_t outWidth, size_t outHeight );
extern void DumpGLBuffer(GLenum type, size_t width, size_t height, void* buffer);
extern const char *GetGLTypeName( GLenum type );
extern const char *GetGLAttachmentName( GLenum att );
extern const char *GetGLTargetName( GLenum tgt );
extern const char *GetGLBaseFormatName( GLenum baseformat );
extern const char *GetGLFormatName( GLenum format );
extern void* CreateRandomData( ExplicitType type, size_t count, MTdata d );
extern GLenum GetGLFormat(GLenum internalFormat);
extern GLenum GetGLTypeForExplicitType(ExplicitType type);
extern size_t GetGLTypeSize(GLenum type);
extern ExplicitType GetExplicitTypeForGLType(GLenum type);
extern GLenum get_base_gl_target( GLenum target );
extern int init_clgl_ext( void );
#endif // _helpers_h

View File

@@ -1,204 +0,0 @@
//
// 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.
//
#define GL_GLEXT_PROTOTYPES
#include "setup.h"
#include "testBase.h"
#include "harness/errorHelpers.h"
#include <GL/gl.h>
#include <GL/glut.h>
#include <GL/glext.h>
#include <GL/glut.h>
#include <CL/cl_ext.h>
typedef CL_API_ENTRY cl_int (CL_API_CALL *clGetGLContextInfoKHR_fn)(
const cl_context_properties *properties,
cl_gl_context_info param_name,
size_t param_value_size,
void *param_value,
size_t *param_value_size_ret);
// Rename references to this dynamically linked function to avoid
// collision with static link version
#define clGetGLContextInfoKHR clGetGLContextInfoKHR_proc
static clGetGLContextInfoKHR_fn clGetGLContextInfoKHR;
#define MAX_DEVICES 32
class WGLEnvironment : public GLEnvironment
{
private:
cl_device_id m_devices[MAX_DEVICES];
int m_device_count;
cl_platform_id m_platform;
public:
WGLEnvironment()
{
m_device_count = 0;
m_platform = 0;
}
virtual int Init( int *argc, char **argv, int use_opengl_32 )
{
// Create a GLUT window to render into
glutInit( argc, argv );
glutInitWindowSize( 512, 512 );
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
glutCreateWindow( "OpenCL <-> OpenGL Test" );
glewInit();
return 0;
}
virtual cl_context CreateCLContext( void )
{
HGLRC hGLRC = wglGetCurrentContext();
HDC hDC = wglGetCurrentDC();
cl_context_properties properties[] = {
CL_CONTEXT_PLATFORM, (cl_context_properties) m_platform,
CL_GL_CONTEXT_KHR, (cl_context_properties) hGLRC,
CL_WGL_HDC_KHR, (cl_context_properties) hDC,
0
};
cl_device_id devices[MAX_DEVICES];
size_t dev_size;
cl_int status;
if (!hGLRC || !hDC) {
print_error(CL_INVALID_CONTEXT, "No GL context bound");
return 0;
}
if (!clGetGLContextInfoKHR) {
// As OpenCL for the platforms. Warn if more than one platform found,
// since this might not be the platform we want. By default, we simply
// use the first returned platform.
cl_uint nplatforms;
cl_platform_id platform;
clGetPlatformIDs(0, NULL, &nplatforms);
clGetPlatformIDs(1, &platform, NULL);
if (nplatforms > 1) {
log_info("clGetPlatformIDs returned multiple values. This is not "
"an error, but might result in obtaining incorrect function "
"pointers if you do not want the first returned platform.\n");
// Show them the platform name, in case it is a problem.
size_t size;
char *name;
clGetPlatformInfo(platform, CL_PLATFORM_NAME, 0, NULL, &size);
name = (char*)malloc(size);
clGetPlatformInfo(platform, CL_PLATFORM_NAME, size, name, NULL);
log_info("Using platform with name: %s \n", name);
free(name);
}
clGetGLContextInfoKHR = (clGetGLContextInfoKHR_fn) clGetExtensionFunctionAddressForPlatform(platform, "clGetGLContextInfoKHR");
if (!clGetGLContextInfoKHR) {
print_error(CL_INVALID_PLATFORM, "Failed to query proc address for clGetGLContextInfoKHR");
}
}
status = clGetGLContextInfoKHR(properties,
CL_DEVICES_FOR_GL_CONTEXT_KHR,
sizeof(devices),
devices,
&dev_size);
if (status != CL_SUCCESS) {
print_error(status, "clGetGLContextInfoKHR failed");
return 0;
}
dev_size /= sizeof(cl_device_id);
log_info("GL context supports %d compute devices\n", dev_size);
status = clGetGLContextInfoKHR(properties,
CL_CURRENT_DEVICE_FOR_GL_CONTEXT_KHR,
sizeof(devices),
devices,
&dev_size);
if (status != CL_SUCCESS) {
print_error(status, "clGetGLContextInfoKHR failed");
return 0;
}
cl_device_id ctxDevice = m_devices[0];
if (dev_size > 0) {
log_info("GL context current device: 0x%x\n", devices[0]);
for (int i = 0; i < m_device_count; i++) {
if (m_devices[i] == devices[0]) {
ctxDevice = devices[0];
break;
}
}
} else {
log_info("GL context current device is not a CL device, using device %d.\n", ctxDevice);
}
return clCreateContext(properties, 1, &ctxDevice, NULL, NULL, &status);
}
virtual int SupportsCLGLInterop( cl_device_type device_type )
{
cl_device_id devices[MAX_DEVICES];
cl_uint num_of_devices;
int error;
error = clGetPlatformIDs(1, &m_platform, NULL);
if (error) {
print_error(error, "clGetPlatformIDs failed");
return -1;
}
error = clGetDeviceIDs(m_platform, device_type, MAX_DEVICES, devices, &num_of_devices);
if (error) {
print_error(error, "clGetDeviceIDs failed");
return -1;
}
// Check all devices, search for one that supports cl_khr_gl_sharing
char extensions[8192];
for (int i=0; i<(int)num_of_devices; i++) {
error = clGetDeviceInfo(devices[i], CL_DEVICE_EXTENSIONS, sizeof(extensions), extensions, NULL);
if (error) {
print_error(error, "clGetDeviceInfo failed");
return -1;
}
if (strstr(extensions, "cl_khr_gl_sharing") == NULL) {
log_info("Device %d of %d does not support required extension cl_khr_gl_sharing.\n", i+1, num_of_devices);
} else {
log_info("Device %d of %d supports required extension cl_khr_gl_sharing.\n", i+1, num_of_devices);
m_devices[m_device_count++] = devices[i];
}
}
return m_device_count > 0;
}
virtual ~WGLEnvironment()
{
}
};
GLEnvironment * GLEnvironment::Instance( void )
{
static WGLEnvironment * env = NULL;
if( env == NULL )
env = new WGLEnvironment();
return env;
}