diff --git a/crates/redpiler/src/backend/direct/compile.rs b/crates/redpiler/src/backend/direct/compile.rs index f689b504..3cf4f971 100644 --- a/crates/redpiler/src/backend/direct/compile.rs +++ b/crates/redpiler/src/backend/direct/compile.rs @@ -67,6 +67,10 @@ fn compile_node( stats.default_link_count += default_input_count; stats.side_link_count += side_input_count; + // Make sure signal strength buckets add up to 255 so we can easily check for all zeros in get_bool_input + default_inputs.ss_counts[0] += (MAX_INPUTS - default_input_count) as u8; + side_inputs.ss_counts[0] += (MAX_INPUTS - side_input_count) as u8; + use crate::compile_graph::NodeType as CNodeType; let updates = if node.ty != CNodeType::Constant { graph diff --git a/crates/redpiler/src/backend/direct/mod.rs b/crates/redpiler/src/backend/direct/mod.rs index 5a090354..f1a4c36f 100644 --- a/crates/redpiler/src/backend/direct/mod.rs +++ b/crates/redpiler/src/backend/direct/mod.rs @@ -308,16 +308,14 @@ fn schedule_tick( scheduler.schedule_tick(node_id, delay, priority); } -const BOOL_INPUT_MASK: u128 = u128::from_ne_bytes([ - 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, -]); - fn get_bool_input(node: &Node) -> bool { - u128::from_le_bytes(node.default_inputs.ss_counts) & BOOL_INPUT_MASK != 0 + // During compilation its ensured all signal strength buckets add up to 255 + // So if and only if the zero bucket contains 255 is the input zero + node.default_inputs.ss_counts[0] != 255 } fn get_bool_side(node: &Node) -> bool { - u128::from_le_bytes(node.side_inputs.ss_counts) & BOOL_INPUT_MASK != 0 + node.side_inputs.ss_counts[0] != 255 } fn last_index_positive(array: &[u8; 16]) -> u32 {