Skip to content

Commit

Permalink
Upgrade rspirv dependency to 0.12 and fix recent clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
MarijnS95 committed Nov 1, 2024
1 parent c4c6874 commit f52f6de
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
26 changes: 13 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand All @@ -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 => {
Expand All @@ -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)
}
Expand Down Expand Up @@ -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,
}
Expand Down

0 comments on commit f52f6de

Please sign in to comment.