mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 00:40:09 +01:00
nak: Restructure for better module separation
With this commit, NAK now takes on a more Cargo-like structure with
things split better into crates:
- bitview/
- lib.rs // Formerly bitview.rs
- nak/
- lib.rs // Only pulls stuff into the module
- api.rs // Formerly nak.rs
- ...
- nvfuzz/
- main.rs // Formerly nvfuzz.rs
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26546>
This commit is contained in:
parent
97cd55d065
commit
03f1b99f50
29 changed files with 100 additions and 86 deletions
|
|
@ -28,8 +28,22 @@ libnak_c_files = files(
|
|||
'nak_nir_lower_gs_intrinsics.c',
|
||||
)
|
||||
|
||||
libnak_rs_files = files(
|
||||
'nak.rs',
|
||||
_libbitview_rs = static_library(
|
||||
'bitview',
|
||||
files('bitview/lib.rs'),
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
rust_abi : 'rust',
|
||||
rust_args : [
|
||||
# we error on all clippy warnings unless they are disabled
|
||||
'-Dclippy::all',
|
||||
# we want to add asserts in control flow
|
||||
'-Aclippy::assertions_on_constants',
|
||||
# dunno, kind of looks nicier being explicit
|
||||
'-Aclippy::redundant_field_names',
|
||||
'-Aclippy::too_many_arguments',
|
||||
'-Aclippy::type_complexity',
|
||||
'-Anon_snake_case',
|
||||
],
|
||||
)
|
||||
|
||||
libnak_deps = [
|
||||
|
|
@ -80,15 +94,15 @@ libnak_bindings_gen = static_library(
|
|||
rust_abi : 'rust',
|
||||
)
|
||||
|
||||
libnak_ir_proc = rust.proc_macro(
|
||||
_libnak_ir_proc_rs = rust.proc_macro(
|
||||
'nak_ir_proc',
|
||||
files('nak_ir_proc.rs'),
|
||||
files('nak/ir_proc.rs'),
|
||||
dependencies : [dep_syn],
|
||||
)
|
||||
|
||||
_libnak_rs = static_library(
|
||||
'nak_rs',
|
||||
[libnak_rs_files],
|
||||
files('nak/lib.rs'),
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
rust_abi : 'c',
|
||||
rust_args : [
|
||||
|
|
@ -102,7 +116,7 @@ _libnak_rs = static_library(
|
|||
'-Aclippy::type_complexity',
|
||||
'-Anon_snake_case',
|
||||
],
|
||||
link_with: [libnak_bindings_gen, libnak_ir_proc],
|
||||
link_with: [_libbitview_rs, libnak_bindings_gen, _libnak_ir_proc_rs],
|
||||
)
|
||||
|
||||
_libnak = static_library(
|
||||
|
|
@ -118,8 +132,9 @@ _libnak = static_library(
|
|||
if with_tools.contains('nouveau')
|
||||
executable(
|
||||
'nvfuzz',
|
||||
files('nvfuzz.rs'),
|
||||
files('nvfuzz/main.rs'),
|
||||
rust_crate_type : 'bin',
|
||||
link_with: [_libbitview_rs],
|
||||
install : true
|
||||
)
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -1,37 +1,12 @@
|
|||
/*
|
||||
* Copyright © 2022 Collabora, Ltd.
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
// Copyright © 2022 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
mod bitset;
|
||||
mod bitview;
|
||||
mod nak_assign_regs;
|
||||
mod nak_builder;
|
||||
mod nak_calc_instr_deps;
|
||||
mod nak_cfg;
|
||||
mod nak_encode_sm70;
|
||||
mod nak_from_nir;
|
||||
mod nak_ir;
|
||||
mod nak_legalize;
|
||||
mod nak_liveness;
|
||||
mod nak_lower_copy_swap;
|
||||
mod nak_lower_par_copies;
|
||||
mod nak_opt_bar_prop;
|
||||
mod nak_opt_copy_prop;
|
||||
mod nak_opt_dce;
|
||||
mod nak_opt_lop;
|
||||
mod nak_opt_out;
|
||||
mod nak_repair_ssa;
|
||||
mod nak_sph;
|
||||
mod nak_spill_values;
|
||||
mod nak_to_cssa;
|
||||
mod nir;
|
||||
|
||||
use crate::nak_ir::ShaderStageInfo;
|
||||
use crate::from_nir::*;
|
||||
use crate::ir::{ShaderIoInfo, ShaderStageInfo};
|
||||
use crate::sph;
|
||||
|
||||
use nak_bindings::*;
|
||||
use nak_from_nir::*;
|
||||
use nak_ir::ShaderIoInfo;
|
||||
|
||||
use std::cmp::max;
|
||||
use std::env;
|
||||
use std::ffi::{CStr, CString};
|
||||
|
|
@ -46,7 +21,7 @@ enum DebugFlags {
|
|||
Spill,
|
||||
}
|
||||
|
||||
struct Debug {
|
||||
pub struct Debug {
|
||||
flags: u32,
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +48,7 @@ impl Debug {
|
|||
}
|
||||
}
|
||||
|
||||
trait GetDebugFlags {
|
||||
pub trait GetDebugFlags {
|
||||
fn debug_flags(&self) -> u32;
|
||||
|
||||
fn print(&self) -> bool {
|
||||
|
|
@ -89,7 +64,7 @@ trait GetDebugFlags {
|
|||
}
|
||||
}
|
||||
|
||||
static DEBUG: OnceLock<Debug> = OnceLock::new();
|
||||
pub static DEBUG: OnceLock<Debug> = OnceLock::new();
|
||||
|
||||
impl GetDebugFlags for OnceLock<Debug> {
|
||||
fn debug_flags(&self) -> u32 {
|
||||
|
|
@ -397,7 +372,7 @@ pub extern "C" fn nak_compile_shader(
|
|||
}
|
||||
_ => unsafe { std::mem::zeroed() },
|
||||
},
|
||||
hdr: nak_sph::encode_header(&s.info, fs_key),
|
||||
hdr: sph::encode_header(&s.info, fs_key),
|
||||
};
|
||||
|
||||
let mut asm = String::new();
|
||||
|
|
@ -4,8 +4,8 @@
|
|||
*/
|
||||
|
||||
use crate::bitset::BitSet;
|
||||
use crate::nak_ir::*;
|
||||
use crate::nak_liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
use crate::ir::*;
|
||||
use crate::liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
|
||||
use std::cmp::{max, Ordering};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
pub trait Builder {
|
||||
fn push_instr(&mut self, instr: Box<Instr>) -> &mut Instr;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// Copyright © 2022 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::{GetDebugFlags, DEBUG};
|
||||
use crate::api::{GetDebugFlags, DEBUG};
|
||||
use crate::ir::*;
|
||||
|
||||
use std::cmp::max;
|
||||
use std::collections::HashSet;
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::bitview::*;
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
use bitview::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::ops::Range;
|
||||
|
|
@ -5,10 +5,10 @@
|
|||
|
||||
#![allow(non_upper_case_globals)]
|
||||
|
||||
use crate::nak_cfg::CFGBuilder;
|
||||
use crate::nak_ir::*;
|
||||
use crate::nak_sph::{OutputTopology, PixelImap};
|
||||
use crate::cfg::CFGBuilder;
|
||||
use crate::ir::*;
|
||||
use crate::nir::*;
|
||||
use crate::sph::{OutputTopology, PixelImap};
|
||||
|
||||
use nak_bindings::*;
|
||||
|
||||
|
|
@ -3,15 +3,15 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
extern crate bitview;
|
||||
extern crate nak_ir_proc;
|
||||
|
||||
use crate::bitview::BitMutView;
|
||||
pub use crate::nak_builder::{
|
||||
Builder, InstrBuilder, SSABuilder, SSAInstrBuilder,
|
||||
};
|
||||
use crate::nak_cfg::CFG;
|
||||
use crate::nak_sph::{OutputTopology, PixelImap};
|
||||
use crate::{GetDebugFlags, DEBUG};
|
||||
use bitview::BitMutView;
|
||||
|
||||
use crate::api::{GetDebugFlags, DEBUG};
|
||||
pub use crate::builder::{Builder, InstrBuilder, SSABuilder, SSAInstrBuilder};
|
||||
use crate::cfg::CFG;
|
||||
use crate::sph::{OutputTopology, PixelImap};
|
||||
use nak_ir_proc::*;
|
||||
use std::cmp::{max, min};
|
||||
use std::fmt;
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::nak_liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
use crate::ir::*;
|
||||
use crate::liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
26
src/nouveau/compiler/nak/lib.rs
Normal file
26
src/nouveau/compiler/nak/lib.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
// Copyright © 2023 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
mod api;
|
||||
mod assign_regs;
|
||||
mod bitset;
|
||||
mod builder;
|
||||
mod calc_instr_deps;
|
||||
mod cfg;
|
||||
mod encode_sm70;
|
||||
mod from_nir;
|
||||
mod ir;
|
||||
mod legalize;
|
||||
mod liveness;
|
||||
mod lower_copy_swap;
|
||||
mod lower_par_copies;
|
||||
mod nir;
|
||||
mod opt_bar_prop;
|
||||
mod opt_copy_prop;
|
||||
mod opt_dce;
|
||||
mod opt_lop;
|
||||
mod opt_out;
|
||||
mod repair_ssa;
|
||||
mod sph;
|
||||
mod spill_values;
|
||||
mod to_cssa;
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
use crate::bitset::BitSet;
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{max, Ord, Ordering};
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
// Copyright © 2022 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::cmp::max;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::bitset::BitSet;
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::slice;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
fn try_combine_outs(emit: &mut Instr, cut: &Instr) -> bool {
|
||||
let Op::Out(emit) = &mut emit.op else {
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::bitset::BitSet;
|
||||
use crate::nak_ir::*;
|
||||
use crate::ir::*;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
|
|
@ -1,17 +1,15 @@
|
|||
// Copyright © 2023 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use std::ops::Range;
|
||||
extern crate bitview;
|
||||
|
||||
use nak_bindings::*;
|
||||
|
||||
use crate::{
|
||||
bitview::{
|
||||
BitMutView, BitMutViewable, BitView, BitViewable, SetBit, SetField,
|
||||
SetFieldU64,
|
||||
},
|
||||
nak_ir::{ShaderInfo, ShaderIoInfo, ShaderStageInfo},
|
||||
use crate::ir::{ShaderInfo, ShaderIoInfo, ShaderStageInfo};
|
||||
use bitview::{
|
||||
BitMutView, BitMutViewable, BitView, BitViewable, SetBit, SetField,
|
||||
SetFieldU64,
|
||||
};
|
||||
use nak_bindings::*;
|
||||
use std::ops::Range;
|
||||
|
||||
pub const _FERMI_SHADER_HEADER_SIZE: usize = 20;
|
||||
pub const TURING_SHADER_HEADER_SIZE: usize = 32;
|
||||
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
#![allow(unstable_name_collisions)]
|
||||
|
||||
use crate::api::{GetDebugFlags, DEBUG};
|
||||
use crate::bitset::BitSet;
|
||||
use crate::nak_ir::*;
|
||||
use crate::nak_liveness::{
|
||||
use crate::ir::*;
|
||||
use crate::liveness::{
|
||||
BlockLiveness, LiveSet, Liveness, NextUseBlockLiveness, NextUseLiveness,
|
||||
};
|
||||
use crate::{GetDebugFlags, DEBUG};
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::cmp::{max, Ordering, Reverse};
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// Copyright © 2023 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::nak_cfg::CFG;
|
||||
use crate::nak_ir::*;
|
||||
use crate::nak_liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
use crate::cfg::CFG;
|
||||
use crate::ir::*;
|
||||
use crate::liveness::{BlockLiveness, Liveness, SimpleLiveness};
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::iter::Peekable;
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
mod bitview;
|
||||
extern crate bitview;
|
||||
|
||||
use crate::bitview::*;
|
||||
|
||||
Loading…
Add table
Reference in a new issue