From f52f6dec9d820125024c4326fd258c446ad1038c Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Fri, 1 Nov 2024 11:31:32 +0100 Subject: [PATCH] Upgrade `rspirv` dependency to `0.12` and fix recent clippy lints --- Cargo.toml | 2 +- README.md | 2 +- src/lib.rs | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 223aa73..0879062 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,5 +14,5 @@ documentation = "https://docs.rs/rspirv-reflect" include = ["/src", "/LICENSE-APACHE", "/LICENSE-MIT"] [dependencies] -rspirv = "0.11" +rspirv = "0.12" thiserror = "1.0" diff --git a/README.md b/README.md index d6331b3..3101f47 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ [![Banner](banner.png)](https://traverseresearch.nl) -This is a minimal dependency, SPIR-V reflection library written in rust. It uses the [rspirv](https://github.com/gfx-rs/rspirv/) crate as it's basis. As of writing it supports SPIR-V up to and including version 1.5. +This is a minimal-dependency, SPIR-V reflection library written in Rust. It uses the [rspirv](https://github.com/gfx-rs/rspirv/) crate at its basis. As of writing it supports SPIR-V up to and including version 1.6. ```toml [dependencies] diff --git a/src/lib.rs b/src/lib.rs index 98c3f2b..0b4c875 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -226,10 +226,10 @@ impl Reflection { pub fn get_compute_group_size(&self) -> Option<(u32, u32, u32)> { for inst in self.0.global_inst_iter() { if inst.class.opcode == spirv::Op::ExecutionMode { - use rspirv::dr::Operand::{ExecutionMode, LiteralInt32}; + use rspirv::dr::Operand::{ExecutionMode, LiteralBit32}; if let [ExecutionMode( spirv::ExecutionMode::LocalSize | spirv::ExecutionMode::LocalSizeHint, - ), LiteralInt32(x), LiteralInt32(y), LiteralInt32(z)] = inst.operands[1..] + ), LiteralBit32(x), LiteralBit32(y), LiteralBit32(z)] = inst.operands[1..] { return Some((x, y, z)); } else { @@ -274,10 +274,10 @@ impl Reflection { )?; // Array size can be any width, any signedness assert_eq!(num_elements_ty.class.opcode, spirv::Op::TypeInt); - let num_elements = match get_operand_at!(num_elements_ty, Operand::LiteralInt32, 0)? + let num_elements = match get_operand_at!(num_elements_ty, Operand::LiteralBit32, 0)? { - 32 => get_operand_at!(num_elements, Operand::LiteralInt32, 0)?.try_into()?, - 64 => get_operand_at!(num_elements, Operand::LiteralInt64, 0)?.try_into()?, + 32 => get_operand_at!(num_elements, Operand::LiteralBit32, 0)?.try_into()?, + 64 => get_operand_at!(num_elements, Operand::LiteralBit64, 0)?.try_into()?, x => return Err(ReflectError::UnexpectedIntWidth(x)), }; assert!(num_elements >= 1); @@ -337,7 +337,7 @@ impl Reflection { const IMAGE_STORAGE: u32 = 2; // TODO: Should this be modeled as an enum in rspirv?? - let sampled = get_operand_at!(type_instruction, Operand::LiteralInt32, 5)?; + let sampled = get_operand_at!(type_instruction, Operand::LiteralBit32, 5)?; if dim == spirv::Dim::DimBuffer { if sampled == IMAGE_SAMPLED { @@ -475,7 +475,7 @@ impl Reflection { (None, None), |state, a| { if let Operand::Decoration(d) = a.operands[1] { - if let Operand::LiteralInt32(i) = a.operands[2] { + if let Operand::LiteralBit32(i) = a.operands[2] { if d == spirv::Decoration::DescriptorSet { assert!(state.0.is_none(), "Set already has a value!"); return (Some(i), state.1); @@ -545,8 +545,8 @@ impl Reflection { .iter() .filter(|i| i.class.opcode == spirv::Op::MemberDecorate) .filter_map(|&i| match get_operand_at!(i, Operand::Decoration, 2) { - Ok(decoration) if decoration == spirv::Decoration::Offset => { - Some(get_operand_at!(i, Operand::LiteralInt32, 3)) + Ok(spirv::Decoration::Offset) => { + Some(get_operand_at!(i, Operand::LiteralBit32, 3)) } Err(err) => Some(Err(err)), _ => None, @@ -565,7 +565,7 @@ impl Reflection { match type_instruction.class.opcode { spirv::Op::TypeInt | spirv::Op::TypeFloat => { debug_assert!(!type_instruction.operands.is_empty()); - Ok(get_operand_at!(type_instruction, Operand::LiteralInt32, 0)? / 8) + Ok(get_operand_at!(type_instruction, Operand::LiteralBit32, 0)? / 8) } spirv::Op::TypeVector | spirv::Op::TypeMatrix => { debug_assert!(type_instruction.operands.len() == 2); @@ -576,7 +576,7 @@ impl Reflection { Self::calculate_variable_size_bytes(reflect, var_type_instruction)?; let type_constant_count = - get_operand_at!(type_instruction, Operand::LiteralInt32, 1)?; + get_operand_at!(type_instruction, Operand::LiteralBit32, 1)?; Ok(type_size_bytes * type_constant_count) } spirv::Op::TypeArray => { @@ -591,7 +591,7 @@ impl Reflection { let constant_instruction = Self::find_assignment_for(&reflect.types_global_values, var_constant_id)?; let type_constant_count = - get_operand_at!(constant_instruction, Operand::LiteralInt32, 0)?; + get_operand_at!(constant_instruction, Operand::LiteralBit32, 0)?; Ok(type_size_bytes * type_constant_count) } @@ -642,7 +642,7 @@ impl Reflection { .filter_map(|i| { let cls = get_operand_at!(*i, Operand::StorageClass, 0); match cls { - Ok(cls) if cls == spirv::StorageClass::PushConstant => Some(Ok(i)), + Ok(spirv::StorageClass::PushConstant) => Some(Ok(i)), Err(err) => Some(Err(err)), _ => None, }