with_intel_vk_rt = false
endif
with_clc = with_microsoft_clc or with_intel_clc
-with_libclc = with_clc
with_spirv_to_dxil = get_option('spirv-to-dxil')
if host_machine.system() == 'darwin'
error('The Clover OpenCL state tracker requires rtti')
endif
- with_libclc = true
+ with_clc = true
with_gallium_opencl = true
with_opencl_icd = _opencl == 'icd'
else
add_languages('rust', required: true)
with_clc = true
- with_libclc = true
endif
dep_clc = null_dep
-if with_libclc
+if with_clc
dep_clc = dependency('libclc')
endif
#include "nir_types.h"
#include "clc.h"
#include "clc_helpers.h"
+#include "nir_clc_helpers.h"
#include "spirv/nir_spirv.h"
#include "util/u_debug.h"
files_libmesaclc = files(
'clc.c',
'clc_helpers.cpp',
+ 'nir_load_libclc.c',
+ 'nir_lower_libclc.c',
)
+_libmesaclc_c_args = []
_libmesaclc_cpp_args = ['-DLLVM_LIB_DIR="@0@"'.format(llvm_libdir)]
_libmesaclc_sources = []
_libmesaclc_cpp_args += ['-DHAS_SPIRV_1_4=1']
endif
+_basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
+
+_static_libclc = get_option('static-libclc')
+if _static_libclc.length() > 0
+ if _static_libclc.contains('all')
+ _static_libclc = ['spirv', 'spirv64']
+ endif
+ prog_zstd = find_program('zstd', required : false, native : true)
+ _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
+ if _zstd_static_libclc
+ _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
+ endif
+ foreach s : _static_libclc
+ _libmesaclc_c_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
+ f = '@0@-mesa3d-.spv'.format(s)
+ _libclc_file = _basedir / f
+ if _zstd_static_libclc
+ _libclc_file = custom_target(
+ '@0@.zstd'.format(f),
+ command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
+ input : [_libclc_file],
+ output : '@0@.zstd'.format(f),
+ )
+ endif
+ files_libmesaclc += custom_target(
+ '@0@.h'.format(f),
+ command : [
+ prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
+ '-n', 'libclc_@0@_mesa3d_spv'.format(s),
+ ],
+ input : [_libclc_file],
+ output : '@0@.h'.format(f),
+ depend_files : files_xxd,
+ )
+ endforeach
+else
+ _libmesaclc_c_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
+ if not cc.has_function('mmap')
+ error('mmap required for dynamic libCLC loading')
+ endif
+endif
+
_libmesaclc = static_library(
'libmesaclc',
files_libmesaclc,
sources: _libmesaclc_sources,
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_compiler, inc_spirv],
- cpp_args : _libmesaclc_cpp_args,
- dependencies: [idep_nir_headers, dep_clang, dep_llvm, dep_llvmspirvlib,
- idep_mesautil, idep_nir, dep_spirv_tools]
+ c_args : _libmesaclc_c_args,
+ cpp_args : [_libmesaclc_cpp_args, _libmesaclc_c_args],
+ dependencies: [idep_nir, dep_clang, dep_llvm, dep_llvmspirvlib,
+ idep_mesautil, dep_spirv_tools]
)
idep_mesaclc = declare_dependency(
--- /dev/null
+/*
+ * Copyright 2023 Intel Corporation
+ * SPDX-License-Identifier: MIT
+ */
+
+#ifndef MESA_NIR_CLC_H
+#define MESA_NIR_CLC_H
+
+#include "nir.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct disk_cache;
+struct spirv_to_nir_options;
+
+bool nir_can_find_libclc(unsigned ptr_bit_size);
+
+nir_shader *
+nir_load_libclc_shader(unsigned ptr_bit_size,
+ struct disk_cache *disk_cache,
+ const struct spirv_to_nir_options *spirv_options,
+ const nir_shader_compiler_options *nir_options);
+
+bool nir_lower_libclc(nir_shader *shader, const nir_shader *clc_shader);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MESA_NIR_CLC_H */
*/
#include "nir.h"
+#include "nir_clc_helpers.h"
#include "nir_serialize.h"
#include "nir_spirv.h"
#include "util/mesa-sha1.h"
* itself to make sure all instances are lowered, before validation.
*/
#include "nir.h"
+#include "nir_clc_helpers.h"
#include "nir_builder.h"
#include "nir_spirv.h"
'../spirv/GLSL.ext.AMD.h',
'../spirv/GLSL.std.450.h',
'../spirv/gl_spirv.c',
- '../spirv/nir_load_libclc.c',
- '../spirv/nir_lower_libclc.c',
'../spirv/nir_spirv.h',
'../spirv/OpenCL.std.h',
'../spirv/spirv.h',
'../spirv/vtn_variables.c',
)
-_libnir_args = []
-if dep_clc.found()
- _basedir = dep_clc.get_variable(pkgconfig : 'libexecdir')
-
- _static_libclc = get_option('static-libclc')
- if _static_libclc.length() > 0
- if _static_libclc.contains('all')
- _static_libclc = ['spirv', 'spirv64']
- endif
-
- prog_zstd = find_program('zstd', required : false)
- _zstd_static_libclc = dep_zstd.found() and prog_zstd.found()
- if _zstd_static_libclc
- _libnir_args += '-DHAVE_STATIC_LIBCLC_ZSTD'
- endif
-
- foreach s : _static_libclc
- _libnir_args += '-DHAVE_STATIC_LIBCLC_@0@'.format(s.to_upper())
- f = '@0@-mesa3d-.spv'.format(s)
- _libclc_file = _basedir / f
-
- if _zstd_static_libclc
- _libclc_file = custom_target(
- '@0@.zstd'.format(f),
- command : [prog_zstd, '-f', '@INPUT@', '-o', '@OUTPUT@'],
- input : [_libclc_file],
- output : '@0@.zstd'.format(f),
- )
- endif
-
- files_libnir += custom_target(
- '@0@.h'.format(f),
- command : [
- prog_python, files_xxd, '-b', '@INPUT@', '@OUTPUT@',
- '-n', 'libclc_@0@_mesa3d_spv'.format(s),
- ],
- input : [_libclc_file],
- output : '@0@.h'.format(f),
- depend_files : files_xxd,
- )
- endforeach
- else
- _libnir_args += ['-DDYNAMIC_LIBCLC_PATH="@0@/"'.format(_basedir)]
- if not cc.has_function('mmap')
- error('mmap required for dynamic libCLC loading')
- endif
- endif
-endif
-
_libnir = static_library(
'nir',
[files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h,
vtn_gather_types_c, nir_intrinsics_c, nir_intrinsics_h, nir_intrinsics_indices_h, vtn_generator_ids_h],
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux, inc_compiler, include_directories('../spirv')],
- c_args : [c_msvc_compat_args, no_override_init_args, _libnir_args],
+ c_args : [c_msvc_compat_args, no_override_init_args],
gnu_symbol_visibility : 'hidden',
dependencies : dep_valgrind,
link_with : libcompiler,
const struct spirv_to_nir_options *options,
const nir_shader_compiler_options *nir_options);
-bool nir_can_find_libclc(unsigned ptr_bit_size);
-
-nir_shader *
-nir_load_libclc_shader(unsigned ptr_bit_size,
- struct disk_cache *disk_cache,
- const struct spirv_to_nir_options *spirv_options,
- const nir_shader_compiler_options *nir_options);
-
-bool nir_lower_libclc(nir_shader *shader, const nir_shader *clc_shader);
-
#ifdef __cplusplus
}
#endif
'clnir',
files('nir/invocation.cpp', 'nir/invocation.hpp'),
include_directories : [clover_incs, inc_mesa],
- dependencies : idep_nir,
+ dependencies : [idep_nir, idep_mesaclc],
cpp_args : [clover_opencl_cpp_args, clover_spirv_cpp_args],
gnu_symbol_visibility : 'hidden',
)
#include "util/functional.hpp"
#include <compiler/glsl_types.h>
+#include <compiler/clc/nir_clc_helpers.h>
#include <compiler/nir/nir_builder.h>
#include <compiler/nir/nir_serialize.h>
#include <compiler/spirv/nir_spirv.h>
#include "rusticl_mesa_inline_bindings_wrapper.h"
#include "rusticl_system_bindings.h"
+#include "compiler/clc/nir_clc_helpers.h"
#include "compiler/clc/clc.h"
#include "compiler/clc/clc_helpers.h"
#include "compiler/shader_enums.h"
#include "brw_kernel.h"
#include "brw_nir.h"
+#include "nir_clc_helpers.h"
#include "compiler/nir/nir_builder.h"
#include "compiler/spirv/nir_spirv.h"
#include "dev/intel_debug.h"
*/
#include "nir.h"
+#include "nir_clc_helpers.h"
#include "nir_serialize.h"
#include "glsl_types.h"
#include "nir_types.h"