primitives: use host pointers for openCL
authorDavid Fort <contact@hardening-consulting.com>
Fri, 29 Nov 2019 07:52:37 +0000 (08:52 +0100)
committerakallabeth <akallabeth@users.noreply.github.com>
Fri, 29 Nov 2019 10:59:09 +0000 (11:59 +0100)
Using host pointers may skip the need for copying buffers.

libfreerdp/core/info.c
libfreerdp/primitives/prim_YUV_opencl.c
libfreerdp/primitives/primitives.c

index 1c9506d..ce5dc38 100644 (file)
@@ -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);
index d377575..420082c 100644 (file)
@@ -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");
index f186aa0..defdf9c 100644 (file)
@@ -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;
        }