nak: Add a nir_shader_compiler_options to nak_compiler

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24998>
This commit is contained in:
Faith Ekstrand 2023-01-30 20:53:19 -06:00 committed by Marge Bot
parent 5a86cf2b80
commit 0e4480d8b3
3 changed files with 53 additions and 1 deletions

View file

@ -22,6 +22,9 @@ struct nv_device_info;
struct nak_compiler *nak_compiler_create(const struct nv_device_info *dev);
void nak_compiler_destroy(struct nak_compiler *nak);
const struct nir_shader_compiler_options *
nak_nir_options(const struct nak_compiler *nak);
void nak_optimize_nir(nir_shader *nir, const struct nak_compiler *nak);
void nak_preprocess_nir(nir_shader *nir, const struct nak_compiler *nak);
void nak_postprocess_nir(nir_shader *nir, const struct nak_compiler *nak);

View file

@ -20,6 +20,41 @@ use nak_from_nir::*;
use std::os::raw::c_void;
use util::NextMultipleOf;
fn nir_options(dev: &nv_device_info) -> nir_shader_compiler_options {
let mut op: nir_shader_compiler_options = unsafe { std::mem::zeroed() };
op.lower_fdiv = true;
op.lower_flrp16 = true;
op.lower_flrp32 = true;
op.lower_flrp64 = true;
op.lower_bitfield_extract = true;
op.lower_bitfield_insert = true;
op.lower_pack_half_2x16 = true;
op.lower_pack_unorm_2x16 = true;
op.lower_pack_snorm_2x16 = true;
op.lower_pack_unorm_4x8 = true;
op.lower_pack_snorm_4x8 = true;
op.lower_unpack_half_2x16 = true;
op.lower_unpack_unorm_2x16 = true;
op.lower_unpack_snorm_2x16 = true;
op.lower_unpack_unorm_4x8 = true;
op.lower_unpack_snorm_4x8 = true;
op.lower_extract_byte = true;
op.lower_extract_word = true;
op.lower_insert_byte = true;
op.lower_insert_word = true;
op.lower_cs_local_index_to_id = true;
op.lower_device_index_to_zero = true;
op.lower_uadd_sat = true; // TODO
op.lower_usub_sat = true; // TODO
op.lower_iadd_sat = true; // TODO
op.use_interpolated_input_intrinsics = true;
op.lower_mul_2x32_64 = true; // TODO
op.lower_int64_options = !0;
op
}
#[no_mangle]
pub extern "C" fn nak_compiler_create(
dev: *const nv_device_info,
@ -27,7 +62,10 @@ pub extern "C" fn nak_compiler_create(
assert!(!dev.is_null());
let dev = unsafe { &*dev };
let nak = Box::new(nak_compiler { sm: dev.sm });
let nak = Box::new(nak_compiler {
sm: dev.sm,
nir_options: nir_options(dev),
});
Box::into_raw(nak)
}
@ -37,6 +75,15 @@ pub extern "C" fn nak_compiler_destroy(nak: *mut nak_compiler) {
unsafe { Box::from_raw(nak) };
}
#[no_mangle]
pub extern "C" fn nak_nir_options(
nak: *const nak_compiler,
) -> *const nir_shader_compiler_options {
assert!(!nak.is_null());
let nak = unsafe { &*nak };
&nak.nir_options
}
#[repr(C)]
struct ShaderBin {
bin: nak_shader_bin,

View file

@ -16,6 +16,8 @@ extern "C" {
struct nak_compiler {
uint8_t sm;
struct nir_shader_compiler_options nir_options;
};
#ifdef __cplusplus