1# Copyright (c) 2019-2022, Intel Corporation 2# 3# Permission is hereby granted, free of charge, to any person obtaining a 4# copy of this software and associated documentation files (the "Software"), 5# to deal in the Software without restriction, including without limitation 6# the rights to use, copy, modify, merge, publish, distribute, sublicense, 7# and/or sell copies of the Software, and to permit persons to whom the 8# Software is furnished to do so, subject to the following conditions: 9# 10# The above copyright notice and this permission notice shall be included 11# in all copies or substantial portions of the Software. 12# 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 17# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 18# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 19# OTHER DEALINGS IN THE SOFTWARE. 20 21function(gen_codec_kernel_from_cm) 22 23 set(genx "g11") 24 set(kind "") 25 set(name "codec") 26 set(platform "gen11") 27 28 set(krn ig${name}krn_${genx}) 29 set(krn_dir ${CMAKE_SOURCE_DIR}/media_driver/agnostic/${platform}/${name}/kernel_free) 30 set(out_dir ${CMAKE_SOURCE_DIR}/media_driver/agnostic/${platform}/${name}/kernel_free/cache_kernel) 31 set(kernel_dir ${out_dir}/kernel) 32 set(krn_header ${CMAKE_SOURCE_DIR}/media_driver/agnostic/common/${name}/kernel/${name}krnheader.h) 33 34 message("krn: " ${krn}) 35 message("krn_dir: " ${krn_dir}) 36 message("out_dir: " ${out_dir}) 37 message("kernel_dir: " ${kernel_dir}) 38 message("krn_header: " ${krn_header}) 39 40 add_custom_command( 41 OUTPUT ${out_dir} ${kernel_dir} ${patch_dir} ${kernel_hex_dir} ${patch_hex_dir} 42 COMMAND ${CMAKE_COMMAND} -E make_directory ${out_dir} 43 COMMAND ${CMAKE_COMMAND} -E make_directory ${kernel_dir} 44 COMMENT "Creating ${name} cmfc kernels output directory") 45 46 # Compiling all the sources in the kernel source directory. 47 file(GLOB_RECURSE srcs ${krn_dir}/Source/*.cpp) 48 49 set(objsname "") 50 set(cm_genx icllp) 51 52 foreach(src ${srcs}) 53 get_filename_component(obj ${src} NAME_WE) # there are other outputs from cmc command, but we use only .dat and .fcpatch 54 55 add_custom_command( 56 OUTPUT ${out_dir}/${obj}_0.dat 57 DEPENDS ${src} ${out_dir} 58 WORKING_DIRECTORY ${out_dir} 59 COMMAND ${CMC} 60 -c -Qxcm -Qxcm_jit_target=${cm_genx} 61 -I ${krn_dir}/Source/ 62 -Qxcm_jit_option="-nocompaction -output -binary" 63 -mCM_emit_common_isa 64 -mCM_no_input_reorder 65 #-mCM_unique_labels=MDF_FC 66 -mCM_printregusage 67 -mCM_old_asm_name 68 ${src} 69 COMMENT "Compiling ${src}... to ${out_dir}/${obj}_0.dat\ 70 Checking if renaming is needed..." 71 ) 72 73 set(objsname ${objsname} ${out_dir}/${obj}_0.dat) 74 endforeach() 75 76 add_custom_command( 77 OUTPUT ${krn_dir}/${krn}.c ${krn_dir}/${krn}.h 78 DEPENDS KernelBinToSource ${objsname} 79 WORKING_DIRECTORY ${out_dir} 80 COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}//media_driver/agnostic/common/codec/kernel/merge.py -o ${krn}.krn ${objsname} 81 COMMAND KernelBinToSource -i ${krn}.krn -o ${krn_dir} 82 COMMENT "Generate source file from krn") 83 84endfunction() 85 86if(BUILD_KERNELS) 87 gen_codec_kernel_from_cm() 88endif() 89 90set(TMP_SOURCES_ 91 ${CMAKE_CURRENT_LIST_DIR}/igcodeckrn_g11.c 92) 93 94set(TMP_HEADERS_ 95 ${CMAKE_CURRENT_LIST_DIR}/igcodeckrn_g11.h 96) 97 98set(SOURCES_ 99 ${SOURCES_} 100 ${TMP_SOURCES_} 101) 102 103set(HEADERS_ 104 ${HEADERS_} 105 ${TMP_HEADERS_} 106) 107 108set(CODEC_SOURCES_ 109 ${CODEC_SOURCES_} 110 ${TMP_SOURCES_} 111) 112 113set(CODEC_HEADERS_ 114 ${CODEC_HEADERS_} 115 ${TMP_HEADERS_} 116) 117 118source_group("Kernel\\CodecKernel" FILES ${TMP_SOURCES_} ${TMP_HEADERS_}) 119set(TMP_SOURCES_ "") 120set(TMP_HEADERS_ "") 121 122media_add_curr_to_include_path() 123