#endif
#if defined(WITH_OPENCL)
-<<<<<<< HEAD
-#ifdef __APPLE__
-#include "OpenCL/opencl.h"
-#else
-#include <CL/cl.h>
-#endif
-
-typedef struct
-{
- BOOL support;
- cl_platform_id platformId;
- cl_device_id deviceId;
- cl_context context;
- cl_command_queue commandQueue;
- cl_program program;
- __YUV420ToRGB_8u_P3AC4R_t YUV420ToRGB_backup;
-} primitives_opencl_context;
-
-
-FREERDP_LOCAL BOOL primitives_init_opencl(primitives_t* prims);
-FREERDP_LOCAL pstatus_t primitives_uninit_opencl(void);
-FREERDP_LOCAL primitives_opencl_context *primitives_get_opencl_context(void);
-=======
FREERDP_LOCAL BOOL primitives_init_opencl(primitives_t* prims);
FREERDP_LOCAL pstatus_t primitives_uninit_opencl(void);
->>>>>>> 79139d536... Cleaned up primitives code.
FREERDP_LOCAL void primitives_init_YUV_opencl(primitives_t* prims);
#endif
UINT32 testedFormat;
} primitives_YUV_benchmark;
-static primitives_YUV_benchmark* primitives_YUV_benchmark_init(void)
+static void primitives_YUV_benchmark_free(primitives_YUV_benchmark* bench)
{
int i;
- primitives_YUV_benchmark *ret = calloc(1, sizeof(*ret));
- prim_size_t *roi;
+ if (!bench)
+ return;
+
+ free(bench->outputBuffer);
+
+ for (i = 0; i < 3; i++)
+ free(bench->channels[i]);
+ memset(bench, 0, sizeof(primitives_YUV_benchmark));
+}
+
+static primitives_YUV_benchmark* primitives_YUV_benchmark_init(primitives_YUV_benchmark* ret)
+{
+ int i;
+ prim_size_t* roi;
if (!ret)
return NULL;
+ memset(ret, 0, sizeof(primitives_YUV_benchmark));
roi = &ret->roi;
roi->width = 1024;
roi->height = 768;
-
- ret->outputStride = roi->width *4;
+ ret->outputStride = roi->width * 4;
ret->testedFormat = PIXEL_FORMAT_BGRA32;
- ret->outputBuffer = malloc(roi->width * roi->height * 4);
+ ret->outputBuffer = malloc(ret->outputStride * roi->height);
if (!ret->outputBuffer)
- goto error_output;
+ goto fail;
for (i = 0; i < 3; i++)
{
BYTE *buf = ret->channels[i] = malloc(roi->width * roi->height);
if (!buf)
- goto error_channels;
+ goto fail;
winpr_RAND(buf, roi->width * roi->height);
ret->steps[i] = roi->width;
return ret;
-error_channels:
- for(i = 0; i < 3; i++)
- free(ret->channels[i]);
-error_output:
- free(ret);
- return NULL;
-}
-
-static void primitives_YUV_benchmark_free(primitives_YUV_benchmark **pbench)
-{
- int i;
- primitives_YUV_benchmark *bench;
- if (!*pbench)
- return;
- bench = *pbench;
-
- free(bench->outputBuffer);
-
- for (i = 0; i < 3; i++)
- free(bench->channels[i]);
-
- free(bench);
- *pbench = NULL;
+fail:
+ primitives_YUV_benchmark_free(ret);
+ return ret;
}
static BOOL primitives_YUV_benchmark_run(primitives_YUV_benchmark *bench, primitives_t *prims,
primitives_t* openclPrims = primitives_get_by_type(PRIMITIVES_ONLY_GPU);
UINT32 openclCount = 0;
#endif
- const char *primName = "generic";
-
- primitives_YUV_benchmark *yuvBench = primitives_YUV_benchmark_init();
+ const char* primName = "generic";
+ primitives_YUV_benchmark bench;
+ primitives_YUV_benchmark* yuvBench = primitives_YUV_benchmark_init(&bench);
if (!yuvBench)
return FALSE;
WLog_INFO(TAG, "primitives autodetect, using %s", primName);
ret = TRUE;
out:
- primitives_YUV_benchmark_free(&yuvBench);
+ primitives_YUV_benchmark_free(yuvBench);
return ret;
}
}
}
-void primitives_uninit() {
- if (pPrimitives.uninit)
- pPrimitives.uninit();
+void primitives_uninit()
+{
+#if defined(WITH_OPENCL)
+ if (pPrimitivesGpu.uninit)
+ pPrimitivesGpu.uninit();
+#endif
+#if defined(HAVE_CPU_OPTIMIZED_PRIMITIVES)
+ if (pPrimitivesCpu.uninit)
+ pPrimitivesCpu.uninit();
+#endif
+ if (pPrimitivesGeneric.uninit)
+ pPrimitivesGeneric.uninit();
}
/* ------------------------------------------------------------------------- */