From 22f954970a3d169c1e35ab29c5305c16e6ed5698 Mon Sep 17 00:00:00 2001 From: David Fort Date: Fri, 29 Nov 2019 08:52:37 +0100 Subject: [PATCH] primitives: use host pointers for openCL Using host pointers may skip the need for copying buffers. --- libfreerdp/core/info.c | 8 ++++---- libfreerdp/primitives/prim_YUV_opencl.c | 15 +++------------ libfreerdp/primitives/primitives.c | 2 +- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/libfreerdp/core/info.c b/libfreerdp/core/info.c index 1c9506d..ce5dc38 100644 --- a/libfreerdp/core/info.c +++ b/libfreerdp/core/info.c @@ -906,22 +906,22 @@ static BOOL rdp_write_info_packet(rdpRdp* rdp, wStream* s) /* the mandatory null terminator */ Stream_Write_UINT16(s, 0); - Stream_Write(s, userNameW, cbUserName); + Stream_Write(s, userNameW, cbUserName); /* the mandatory null terminator */ Stream_Write_UINT16(s, 0); - Stream_Write(s, passwordW, cbPassword); + Stream_Write(s, passwordW, cbPassword); /* the mandatory null terminator */ Stream_Write_UINT16(s, 0); - Stream_Write(s, alternateShellW, cbAlternateShell); + Stream_Write(s, alternateShellW, cbAlternateShell); /* the mandatory null terminator */ Stream_Write_UINT16(s, 0); - Stream_Write(s, workingDirW, cbWorkingDir); + Stream_Write(s, workingDirW, cbWorkingDir); /* the mandatory null terminator */ Stream_Write_UINT16(s, 0); diff --git a/libfreerdp/primitives/prim_YUV_opencl.c b/libfreerdp/primitives/prim_YUV_opencl.c index d377575..420082c 100644 --- a/libfreerdp/primitives/prim_YUV_opencl.c +++ b/libfreerdp/primitives/prim_YUV_opencl.c @@ -57,7 +57,6 @@ static pstatus_t opencl_YUVToRGB(const char* kernelName, const BYTE* const pSrc[ cl_mem objs[3] = { NULL, NULL, NULL }; cl_mem destObj; cl_kernel kernel; - cl_event events[3]; size_t indexes[2]; const char* sourceNames[] = { "Y", "U", "V" }; primitives_opencl_context* cl = primitives_get_opencl_context(); @@ -71,21 +70,13 @@ static pstatus_t opencl_YUVToRGB(const char* kernelName, const BYTE* const pSrc[ for (i = 0; i < 3; i++) { - objs[i] = - clCreateBuffer(cl->context, CL_MEM_READ_ONLY, srcStep[i] * roi->height, NULL, &ret); + objs[i] = clCreateBuffer(cl->context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR, + srcStep[i] * roi->height, (char*)pSrc[i], &ret); if (ret != CL_SUCCESS) { WLog_ERR(TAG, "unable to create %sobj", sourceNames[i]); goto error_objs; } - - ret = clEnqueueWriteBuffer(cl->commandQueue, objs[i], CL_FALSE, 0, srcStep[i] * roi->height, - pSrc[i], 0, NULL, &events[i]); - if (ret != CL_SUCCESS) - { - WLog_ERR(TAG, "unable to enqueue write command for %sobj", sourceNames[i]); - goto error_objs; - } } destObj = clCreateBuffer(cl->context, CL_MEM_WRITE_ONLY, dstStep * roi->height, NULL, &ret); @@ -129,7 +120,7 @@ static pstatus_t opencl_YUVToRGB(const char* kernelName, const BYTE* const pSrc[ indexes[0] = roi->width; indexes[1] = roi->height; - ret = clEnqueueNDRangeKernel(cl->commandQueue, kernel, 2, NULL, indexes, NULL, 3, events, NULL); + ret = clEnqueueNDRangeKernel(cl->commandQueue, kernel, 2, NULL, indexes, NULL, 0, NULL, NULL); if (ret != CL_SUCCESS) { WLog_ERR(TAG, "unable to enqueue call kernel"); diff --git a/libfreerdp/primitives/primitives.c b/libfreerdp/primitives/primitives.c index f186aa0..defdf9c 100644 --- a/libfreerdp/primitives/primitives.c +++ b/libfreerdp/primitives/primitives.c @@ -247,7 +247,7 @@ static BOOL primitives_autodetect_best(primitives_t* prims) goto out; } - WLog_DBG(TAG, " * %s\t= %" PRIu32, cur->name, cur->count); + WLog_DBG(TAG, " * %s= %" PRIu32, cur->name, cur->count); if (!best || (best->count < cur->count)) best = cur; } -- 2.7.4