From 00f4325c5a46bf7c46be8646c1eb6f53b632f30a Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Sun, 6 Apr 2014 14:20:19 -0500 Subject: Finish texture sharing test. Make the test modify a GL texture with a CL kernel, then loop over the texture afterwards to check each texel has the right value. Also make the test loop over all platforms and devices that support sharing. --- src/com/jogamp/opencl/util/CLDeviceFilters.java | 2 +- src/com/jogamp/opencl/util/CLPlatformFilters.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/com/jogamp/opencl/util/CLDeviceFilters.java b/src/com/jogamp/opencl/util/CLDeviceFilters.java index a5057fb6..6281b844 100644 --- a/src/com/jogamp/opencl/util/CLDeviceFilters.java +++ b/src/com/jogamp/opencl/util/CLDeviceFilters.java @@ -70,7 +70,7 @@ public class CLDeviceFilters { } /** - * Accepts all devices which support OpenGL-OpenCL interoparability. + * Accepts all devices which support OpenGL-OpenCL interoperability. */ public static Filter glSharing() { return new Filter() { diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java index 48d20916..14e1507e 100644 --- a/src/com/jogamp/opencl/util/CLPlatformFilters.java +++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java @@ -67,7 +67,7 @@ public class CLPlatformFilters { } /** - * Accepts all platforms containing at least one devices of which supports OpenGL-OpenCL interoparability. + * Accepts all platforms containing at least one devices of which supports OpenGL-OpenCL interoperability. */ public static Filter glSharing() { return new Filter() { @@ -86,7 +86,7 @@ public class CLPlatformFilters { /** * Accepts all with the given OpenGL context compatible platforms containing at least one - * devices of which supports OpenGL-OpenCL interoparability. + * devices of which supports OpenGL-OpenCL interoperability. */ public static Filter glSharing(final GLContext context) { return new Filter() { @@ -94,10 +94,22 @@ public class CLPlatformFilters { public boolean accept(CLPlatform item) { String glVendor = context.getGL().glGetString(GL.GL_VENDOR); String clVendor = item.getVendor(); - return clVendor.equals(glVendor) && glFilter.accept(item); + return areVendorsCompatible(glVendor,clVendor) && glFilter.accept(item); } }; } + + /** + * We need this test because on at least some AMD cards, the GL vendor is ATI, + * but the CL vendor is AMD. + * @param glVendor OpenGL vendor string. + * @param clVendor OpenCL vendor string. + * @return true if the strings are either the same, or indicate that they're part of the same card. + */ + private static boolean areVendorsCompatible(final String glVendor, final String clVendor) { + return( clVendor.equals(glVendor) + || (glVendor.contains("ATI Technologies") && clVendor.contains("Advanced Micro Devices"))); + } /** * Accepts all platforms supporting the given extensions. -- cgit v1.2.3 From f98767152049ac141e115dcbb6a6ac66f4831d6a Mon Sep 17 00:00:00 2001 From: Wade Walker Date: Sun, 6 Apr 2014 15:05:46 -0500 Subject: Fix CL-GL interoperability tests on Mac. Fixed detection of compatible interoperability platforms (was silently skipping platform because GL vendor was Nvidia, but CL vendor was Apple). Also fixed CL kernel syntax error about signed-unsigned comparison that ATI's driver on Windows didn't find, and fixed the CL memory object to be write-only instead of read-only (which ATI's Windows driver just ignored). --- src/com/jogamp/opencl/util/CLPlatformFilters.java | 8 +++++--- test/com/jogamp/opencl/gl/CLGLTest.java | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/com/jogamp/opencl/util/CLPlatformFilters.java b/src/com/jogamp/opencl/util/CLPlatformFilters.java index 14e1507e..451c6b1f 100644 --- a/src/com/jogamp/opencl/util/CLPlatformFilters.java +++ b/src/com/jogamp/opencl/util/CLPlatformFilters.java @@ -100,15 +100,17 @@ public class CLPlatformFilters { } /** - * We need this test because on at least some AMD cards, the GL vendor is ATI, - * but the CL vendor is AMD. + * We need this test because: + * - On at least some AMD cards, the GL vendor is ATI, but the CL vendor is AMD. + * - On at least some Macs, the GL vendor is Nvidia, but the CL vendor is Apple. * @param glVendor OpenGL vendor string. * @param clVendor OpenCL vendor string. * @return true if the strings are either the same, or indicate that they're part of the same card. */ private static boolean areVendorsCompatible(final String glVendor, final String clVendor) { return( clVendor.equals(glVendor) - || (glVendor.contains("ATI Technologies") && clVendor.contains("Advanced Micro Devices"))); + || (glVendor.contains("ATI Technologies") && clVendor.contains("Advanced Micro Devices")) + || (glVendor.contains("NVIDIA Corporation") && clVendor.contains("Apple"))); } /** diff --git a/test/com/jogamp/opencl/gl/CLGLTest.java b/test/com/jogamp/opencl/gl/CLGLTest.java index 8c729c08..8c477002 100644 --- a/test/com/jogamp/opencl/gl/CLGLTest.java +++ b/test/com/jogamp/opencl/gl/CLGLTest.java @@ -284,13 +284,13 @@ public class CLGLTest extends UITestCase { // create CLGL buffer ByteBuffer bufferCL = Buffers.newDirectByteBuffer(texWidth*texHeight*4); - CLGLTexture2d clTexture = clglcontext.createFromGLTexture2d(bufferCL, GL2.GL_TEXTURE_2D, id[0], 0, CLBuffer.Mem.READ_ONLY); + CLGLTexture2d clTexture = clglcontext.createFromGLTexture2d(bufferCL, GL2.GL_TEXTURE_2D, id[0], 0, CLBuffer.Mem.WRITE_ONLY); // set texel values to a formula that can be read back and verified String sourceCL = "__kernel void writeTexture (__write_only image2d_t imageTex, unsigned w, unsigned h ) \n" + "{ \n" + - " for(int y=1; y<=h; ++y) { \n" + - " for(int x=1; x<=w; ++x) { \n" + + " for(unsigned y=1; y<=h; ++y) { \n" + + " for(unsigned x=1; x<=w; ++x) { \n" + " write_imagef(imageTex, (int2)(x-1,y-1), (float4)(((float)x)/((float)(4*w)), ((float)y)/((float)(4*h)), 0.0f, 1.0f)); \n" + " } \n" + " } \n" + -- cgit v1.2.3