mirror of
https://github.com/Chaoscaot/schemsearch.git
synced 2025-11-05 05:54:02 +01:00
Rename use_cpu to opencl and adjust logic accordingly.
This commit is contained in:
@ -169,10 +169,10 @@ fn main() {
|
||||
.value_parser(|s: &str| s.parse::<usize>().map_err(|e| e.to_string())),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("force-cpu")
|
||||
.help("Force CPU Matching, skip OpenCL checks")
|
||||
Arg::new("opencl")
|
||||
.help("Use OpenCL Checker")
|
||||
.short('c')
|
||||
.long("force-cpu")
|
||||
.long("opencl")
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.about("Searches for a pattern in a schematic")
|
||||
@ -221,7 +221,7 @@ fn main() {
|
||||
ignore_entities: matches.get_flag("ignore-entities"),
|
||||
threshold: *matches.get_one::<f32>("threshold").expect("Couldn't get threshold"),
|
||||
invalid_nbt: matches.get_flag("invalid-nbt"),
|
||||
use_cpu: matches.get_flag("force-cpu"),
|
||||
opencl: matches.get_flag("opencl"),
|
||||
};
|
||||
|
||||
let pattern = match matches.get_one::<String>("pattern") {
|
||||
|
||||
@ -9,7 +9,7 @@ pub struct SearchBehavior {
|
||||
pub ignore_entities: bool,
|
||||
pub threshold: f32,
|
||||
pub invalid_nbt: bool,
|
||||
pub use_cpu: bool,
|
||||
pub opencl: bool,
|
||||
}
|
||||
|
||||
impl Default for SearchBehavior {
|
||||
@ -22,7 +22,7 @@ impl Default for SearchBehavior {
|
||||
ignore_entities: false,
|
||||
threshold: 0.9,
|
||||
invalid_nbt: false,
|
||||
use_cpu: false,
|
||||
opencl: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,17 +1,10 @@
|
||||
use lazy_static::lazy_static;
|
||||
use math::round::ceil;
|
||||
use schemsearch_common::Match;
|
||||
use schemsearch_files::SpongeSchematic;
|
||||
use schemsearch_ocl_matcher::{ocl_available, ocl_search};
|
||||
use schemsearch_ocl_matcher::ocl_search;
|
||||
use crate::{SearchBehavior};
|
||||
use crate::pattern_mapper::{match_palette, match_palette_adapt};
|
||||
|
||||
lazy_static! {
|
||||
static ref OPENCL_AVAILABLE: bool = {
|
||||
ocl_available()
|
||||
};
|
||||
}
|
||||
|
||||
pub fn search(
|
||||
schem: SpongeSchematic,
|
||||
pattern_schem: &SpongeSchematic,
|
||||
@ -48,7 +41,7 @@ pub fn search(
|
||||
let schem_height = schem.height as usize;
|
||||
let schem_length = schem.length as usize;
|
||||
|
||||
if !search_behavior.use_cpu && *OPENCL_AVAILABLE {
|
||||
if search_behavior.opencl {
|
||||
return ocl_search(schem_data.as_slice(), [schem_width, schem_height, schem_length], pattern_schem.block_data.as_slice(), [pattern_width, pattern_height, pattern_length], *air_id, search_behavior).unwrap()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user