compiler/clc: Move related NIR passes to the common mesa clc
These were historically in the spirv+nir combo, but the common mesa clc is a better home for them. Reviewed-by: Jesse Natalie <jenatali@microsoft.com> Acked-by: Nora Allen <blackcatgames@protonmail.com> Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23667>
This commit is contained in:
@@ -278,7 +278,6 @@ else
|
|||||||
with_intel_vk_rt = false
|
with_intel_vk_rt = false
|
||||||
endif
|
endif
|
||||||
with_clc = with_microsoft_clc or with_intel_clc
|
with_clc = with_microsoft_clc or with_intel_clc
|
||||||
with_libclc = with_clc
|
|
||||||
with_spirv_to_dxil = get_option('spirv-to-dxil')
|
with_spirv_to_dxil = get_option('spirv-to-dxil')
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
if host_machine.system() == 'darwin'
|
||||||
@@ -751,7 +750,7 @@ if _opencl != 'disabled'
|
|||||||
error('The Clover OpenCL state tracker requires rtti')
|
error('The Clover OpenCL state tracker requires rtti')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
with_libclc = true
|
with_clc = true
|
||||||
with_gallium_opencl = true
|
with_gallium_opencl = true
|
||||||
with_opencl_icd = _opencl == 'icd'
|
with_opencl_icd = _opencl == 'icd'
|
||||||
else
|
else
|
||||||
@@ -772,11 +771,10 @@ if with_gallium_rusticl
|
|||||||
add_languages('rust', required: true)
|
add_languages('rust', required: true)
|
||||||
|
|
||||||
with_clc = true
|
with_clc = true
|
||||||
with_libclc = true
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
dep_clc = null_dep
|
dep_clc = null_dep
|
||||||
if with_libclc
|
if with_clc
|
||||||
dep_clc = dependency('libclc')
|
dep_clc = dependency('libclc')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "nir_types.h"
|
#include "nir_types.h"
|
||||||
#include "clc.h"
|
#include "clc.h"
|
||||||
#include "clc_helpers.h"
|
#include "clc_helpers.h"
|
||||||
|
#include "nir_clc_helpers.h"
|
||||||
#include "spirv/nir_spirv.h"
|
#include "spirv/nir_spirv.h"
|
||||||
#include "util/u_debug.h"
|
#include "util/u_debug.h"
|
||||||
|
|
||||||
|
@@ -23,8 +23,11 @@
|
|||||||
files_libmesaclc = files(
|
files_libmesaclc = files(
|
||||||
'clc.c',
|
'clc.c',
|
||||||
'clc_helpers.cpp',
|
'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_cpp_args = ['-DLLVM_LIB_DIR="@0@"'.format(llvm_libdir)]
|
||||||
_libmesaclc_sources = []
|
_libmesaclc_sources = []
|
||||||
|
|
||||||
@@ -70,14 +73,57 @@ if dep_llvm.version().version_compare('>= 14.0')
|
|||||||
_libmesaclc_cpp_args += ['-DHAS_SPIRV_1_4=1']
|
_libmesaclc_cpp_args += ['-DHAS_SPIRV_1_4=1']
|
||||||
endif
|
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 = static_library(
|
||||||
'libmesaclc',
|
'libmesaclc',
|
||||||
files_libmesaclc,
|
files_libmesaclc,
|
||||||
sources: _libmesaclc_sources,
|
sources: _libmesaclc_sources,
|
||||||
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_compiler, inc_spirv],
|
include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_compiler, inc_spirv],
|
||||||
cpp_args : _libmesaclc_cpp_args,
|
c_args : _libmesaclc_c_args,
|
||||||
dependencies: [idep_nir_headers, dep_clang, dep_llvm, dep_llvmspirvlib,
|
cpp_args : [_libmesaclc_cpp_args, _libmesaclc_c_args],
|
||||||
idep_mesautil, idep_nir, dep_spirv_tools]
|
dependencies: [idep_nir, dep_clang, dep_llvm, dep_llvmspirvlib,
|
||||||
|
idep_mesautil, dep_spirv_tools]
|
||||||
)
|
)
|
||||||
|
|
||||||
idep_mesaclc = declare_dependency(
|
idep_mesaclc = declare_dependency(
|
||||||
|
32
src/compiler/clc/nir_clc_helpers.h
Normal file
32
src/compiler/clc/nir_clc_helpers.h
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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 */
|
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nir.h"
|
#include "nir.h"
|
||||||
|
#include "nir_clc_helpers.h"
|
||||||
#include "nir_serialize.h"
|
#include "nir_serialize.h"
|
||||||
#include "nir_spirv.h"
|
#include "nir_spirv.h"
|
||||||
#include "util/mesa-sha1.h"
|
#include "util/mesa-sha1.h"
|
@@ -28,6 +28,7 @@
|
|||||||
* itself to make sure all instances are lowered, before validation.
|
* itself to make sure all instances are lowered, before validation.
|
||||||
*/
|
*/
|
||||||
#include "nir.h"
|
#include "nir.h"
|
||||||
|
#include "nir_clc_helpers.h"
|
||||||
#include "nir_builder.h"
|
#include "nir_builder.h"
|
||||||
#include "nir_spirv.h"
|
#include "nir_spirv.h"
|
||||||
|
|
@@ -301,8 +301,6 @@ files_libnir = files(
|
|||||||
'../spirv/GLSL.ext.AMD.h',
|
'../spirv/GLSL.ext.AMD.h',
|
||||||
'../spirv/GLSL.std.450.h',
|
'../spirv/GLSL.std.450.h',
|
||||||
'../spirv/gl_spirv.c',
|
'../spirv/gl_spirv.c',
|
||||||
'../spirv/nir_load_libclc.c',
|
|
||||||
'../spirv/nir_lower_libclc.c',
|
|
||||||
'../spirv/nir_spirv.h',
|
'../spirv/nir_spirv.h',
|
||||||
'../spirv/OpenCL.std.h',
|
'../spirv/OpenCL.std.h',
|
||||||
'../spirv/spirv.h',
|
'../spirv/spirv.h',
|
||||||
@@ -319,62 +317,13 @@ files_libnir = files(
|
|||||||
'../spirv/vtn_variables.c',
|
'../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(
|
_libnir = static_library(
|
||||||
'nir',
|
'nir',
|
||||||
[files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
|
[files_libnir, spirv_info_c, nir_opt_algebraic_c, nir_opcodes_c,
|
||||||
nir_opcodes_h, nir_constant_expressions_c, nir_builder_opcodes_h,
|
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],
|
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')],
|
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',
|
gnu_symbol_visibility : 'hidden',
|
||||||
dependencies : dep_valgrind,
|
dependencies : dep_valgrind,
|
||||||
link_with : libcompiler,
|
link_with : libcompiler,
|
||||||
|
@@ -143,16 +143,6 @@ nir_shader *spirv_to_nir(const uint32_t *words, size_t word_count,
|
|||||||
const struct spirv_to_nir_options *options,
|
const struct spirv_to_nir_options *options,
|
||||||
const nir_shader_compiler_options *nir_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
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -88,7 +88,7 @@ libclnir = static_library(
|
|||||||
'clnir',
|
'clnir',
|
||||||
files('nir/invocation.cpp', 'nir/invocation.hpp'),
|
files('nir/invocation.cpp', 'nir/invocation.hpp'),
|
||||||
include_directories : [clover_incs, inc_mesa],
|
include_directories : [clover_incs, inc_mesa],
|
||||||
dependencies : idep_nir,
|
dependencies : [idep_nir, idep_mesaclc],
|
||||||
cpp_args : [clover_opencl_cpp_args, clover_spirv_cpp_args],
|
cpp_args : [clover_opencl_cpp_args, clover_spirv_cpp_args],
|
||||||
gnu_symbol_visibility : 'hidden',
|
gnu_symbol_visibility : 'hidden',
|
||||||
)
|
)
|
||||||
|
@@ -32,6 +32,7 @@
|
|||||||
#include "util/functional.hpp"
|
#include "util/functional.hpp"
|
||||||
|
|
||||||
#include <compiler/glsl_types.h>
|
#include <compiler/glsl_types.h>
|
||||||
|
#include <compiler/clc/nir_clc_helpers.h>
|
||||||
#include <compiler/nir/nir_builder.h>
|
#include <compiler/nir/nir_builder.h>
|
||||||
#include <compiler/nir/nir_serialize.h>
|
#include <compiler/nir/nir_serialize.h>
|
||||||
#include <compiler/spirv/nir_spirv.h>
|
#include <compiler/spirv/nir_spirv.h>
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
#include "rusticl_mesa_inline_bindings_wrapper.h"
|
#include "rusticl_mesa_inline_bindings_wrapper.h"
|
||||||
#include "rusticl_system_bindings.h"
|
#include "rusticl_system_bindings.h"
|
||||||
|
|
||||||
|
#include "compiler/clc/nir_clc_helpers.h"
|
||||||
#include "compiler/clc/clc.h"
|
#include "compiler/clc/clc.h"
|
||||||
#include "compiler/clc/clc_helpers.h"
|
#include "compiler/clc/clc_helpers.h"
|
||||||
#include "compiler/shader_enums.h"
|
#include "compiler/shader_enums.h"
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
#include "brw_kernel.h"
|
#include "brw_kernel.h"
|
||||||
#include "brw_nir.h"
|
#include "brw_nir.h"
|
||||||
|
|
||||||
|
#include "nir_clc_helpers.h"
|
||||||
#include "compiler/nir/nir_builder.h"
|
#include "compiler/nir/nir_builder.h"
|
||||||
#include "compiler/spirv/nir_spirv.h"
|
#include "compiler/spirv/nir_spirv.h"
|
||||||
#include "dev/intel_debug.h"
|
#include "dev/intel_debug.h"
|
||||||
|
@@ -22,6 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nir.h"
|
#include "nir.h"
|
||||||
|
#include "nir_clc_helpers.h"
|
||||||
#include "nir_serialize.h"
|
#include "nir_serialize.h"
|
||||||
#include "glsl_types.h"
|
#include "glsl_types.h"
|
||||||
#include "nir_types.h"
|
#include "nir_types.h"
|
||||||
|
Reference in New Issue
Block a user