[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
This commit is contained in:
akallabeth 2024-09-25 07:20:10 +02:00
parent fe590801a1
commit fffabcaab1
No known key found for this signature in database
GPG Key ID: A49454A3FC909FD5
4 changed files with 25 additions and 10 deletions

View File

@ -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

View File

@ -30,6 +30,7 @@
#else
#include <CL/cl.h>
#endif
#include "primitives-opencl-program.h"
#include <freerdp/log.h>
#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;

View File

@ -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 */
}
)

View File

@ -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@ };