From fffabcaab1a5e6987525fecad9709a0e304f4d29 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Wed, 25 Sep 2024 07:20:10 +0200 Subject: [PATCH] [primitives,opencl] Use CMake to include opencl code * Use CMake to convert opencl source file to C constant * Mark opencl sources as headers and add to CMake to show in IDE --- libfreerdp/primitives/CMakeLists.txt | 15 +++++++++++++-- libfreerdp/primitives/opencl/prim_YUV_opencl.c | 5 +---- libfreerdp/primitives/opencl/primitives.cl | 4 ---- libfreerdp/primitives/opencl/primitives.h.in | 11 +++++++++++ 4 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 libfreerdp/primitives/opencl/primitives.h.in diff --git a/libfreerdp/primitives/CMakeLists.txt b/libfreerdp/primitives/CMakeLists.txt index 99222c19c..f85974858 100644 --- a/libfreerdp/primitives/CMakeLists.txt +++ b/libfreerdp/primitives/CMakeLists.txt @@ -64,9 +64,20 @@ set(PRIMITIVES_OPENCL_SRCS ) if (WITH_OPENCL) - freerdp_include_directory_add(${OpenCL_INCLUDE_DIRS}) - freerdp_library_add(OpenCL::OpenCL) + set(FILENAME "opencl/primitives.cl") + set_source_files_properties(${FILENAME} PROPERTIES HEADER_FILE_ONLY ON) + list(APPEND PRIMITIVES_OPENCL_SRCS ${FILENAME}) + include(ConvertFileToHexArray) + file_to_hex_array(${FILENAME} FILEDATA) + + set(HDR_FILE "${CMAKE_CURRENT_BINARY_DIR}/opencl/primitives-opencl-program.h") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/opencl/primitives.h.in" ${HDR_FILE} @ONLY) + list(APPEND PRIMITIVES_OPENCL_SRCS ${HDR_FILE}) + + include_directories(${CMAKE_CURRENT_BINARY_DIR}/opencl) + freerdp_include_directory_add(${OpenCL_INCLUDE_DIRS}) + freerdp_library_add(OpenCL::OpenCL) endif() set(PRIMITIVES_OPT_SRCS diff --git a/libfreerdp/primitives/opencl/prim_YUV_opencl.c b/libfreerdp/primitives/opencl/prim_YUV_opencl.c index e7c9e4efd..b4b53d7c8 100644 --- a/libfreerdp/primitives/opencl/prim_YUV_opencl.c +++ b/libfreerdp/primitives/opencl/prim_YUV_opencl.c @@ -30,6 +30,7 @@ #else #include #endif +#include "primitives-opencl-program.h" #include #define TAG FREERDP_TAG("primitives") @@ -260,10 +261,6 @@ static pstatus_t primitives_uninit_opencl(void) return PRIMITIVES_SUCCESS; } -static const char openclProgram[] = -#include "primitives.cl" - ; - static BOOL primitives_init_opencl_context(primitives_opencl_context* WINPR_RESTRICT prims) { cl_uint ndevices = 0; diff --git a/libfreerdp/primitives/opencl/primitives.cl b/libfreerdp/primitives/opencl/primitives.cl index 5e094df28..796d59ae4 100644 --- a/libfreerdp/primitives/opencl/primitives.cl +++ b/libfreerdp/primitives/opencl/primitives.cl @@ -16,9 +16,6 @@ * permissions and limitations under the License. */ -#define STRINGIFY(x) #x - -STRINGIFY( uchar clamp_uc(int v, short l, short h) { if (v > h) @@ -460,4 +457,3 @@ __kernel void yuv444_to_xrgb_1b( destPtr[1] = clamp_uc((y256 + (403 * V)) >> 8, 0, 255); /* R */ destPtr[0] = 0xff; /* A */ } -) diff --git a/libfreerdp/primitives/opencl/primitives.h.in b/libfreerdp/primitives/opencl/primitives.h.in new file mode 100644 index 000000000..69a4ed4c2 --- /dev/null +++ b/libfreerdp/primitives/opencl/primitives.h.in @@ -0,0 +1,11 @@ +/* AUTOGENERATED file, do not edit + * + * part of @PROJECT_NAME@ + * generated from libfreerdp/primitives/opencl/primitives.h.in + * + * with file contents of @FILENAME@ + */ +#pragma once + +static const char openclProgram[] = { @FILEDATA@ }; +