giving a chance for OpenCL 1.1 devices

pull/5261/head
Andrey Pavlenko 9 years ago
parent 8031742817
commit 74fcefedcb
  1. 7
      samples/android/tutorial-4-opencl/jni/CLprocessor.cpp
  2. 8
      samples/android/tutorial-4-opencl/jni/GLrender.cpp

@ -1,4 +1,5 @@
#define __CL_ENABLE_EXCEPTIONS
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS /*let's give a chance for OpenCL 1.1 devices*/
#include <CL/cl.hpp>
#include <EGL/egl.h>
@ -182,12 +183,12 @@ void procOCL_I2I(int texIn, int texOut, int w, int h)
LOGD("enqueueReleaseGLObjects() costs %d ms", getTimeInterval(t));
}
void procOCL_OCV(int tex, int w, int h)
void procOCL_OCV(int texIn, int texOut, int w, int h)
{
if(!haveOpenCL) return;
int64_t t = getTimeMs();
cl::ImageGL imgIn (theContext, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, tex);
cl::ImageGL imgIn (theContext, CL_MEM_READ_ONLY, GL_TEXTURE_2D, 0, texIn);
std::vector < cl::Memory > images(1, imgIn);
theQueue.enqueueAcquireGLObjects(&images);
theQueue.finish();
@ -204,7 +205,7 @@ void procOCL_OCV(int tex, int w, int h)
LOGD("OpenCV processing costs %d ms", getTimeInterval(t));
t = getTimeMs();
cl::ImageGL imgOut(theContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, tex);
cl::ImageGL imgOut(theContext, CL_MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, texOut);
images.clear();
images.push_back(imgOut);
theQueue.enqueueAcquireGLObjects(&images);

@ -31,7 +31,7 @@ const char vss[] = \
"varying vec2 texCoord;\n" \
"void main() {\n" \
" texCoord = vTexCoord;\n" \
" gl_Position = vec4 ( vPosition, 0.0f, 1.0f );\n" \
" gl_Position = vec4 ( vPosition, 0.0, 1.0 );\n" \
"}";
const char fssOES[] = \
@ -268,7 +268,7 @@ void drawFrameProcCPU()
}
void procOCL_I2I(int texIn, int texOut, int w, int h);
void procOCL_OCV(int tex, int w, int h);
void procOCL_OCV(int texIn, int texOut, int w, int h);
void drawFrameProcOCL()
{
drawTex(texOES, GL_TEXTURE_EXTERNAL_OES, FBO);
@ -285,10 +285,10 @@ void drawFrameProcOCLOCV()
drawTex(texOES, GL_TEXTURE_EXTERNAL_OES, FBO);
// modify pixels in FBO texture using OpenCL and CL-GL interop
procOCL_OCV(FBOtex, texWidth, texHeight);
procOCL_OCV(FBOtex, FBOtex2, texWidth, texHeight);
// render to screen
drawTex(FBOtex, GL_TEXTURE_2D, 0);
drawTex(FBOtex2, GL_TEXTURE_2D, 0);
}
extern "C" void drawFrame()

Loading…
Cancel
Save