From 93b7dd9316a59e2304201368cefa260c37d403b2 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 13 Feb 2024 13:23:43 +0800 Subject: [PATCH 1/3] SPIR-V asm detailed operand enum error report --- .../scripts/generate_operand_enum_type.py | 12 +- .../src/generated/operand_enum_type.rs | 215 +++++++++--------- 2 files changed, 116 insertions(+), 111 deletions(-) diff --git a/spirq-spvasm/scripts/generate_operand_enum_type.py b/spirq-spvasm/scripts/generate_operand_enum_type.py index ec99a40..ac7c77f 100644 --- a/spirq-spvasm/scripts/generate_operand_enum_type.py +++ b/spirq-spvasm/scripts/generate_operand_enum_type.py @@ -31,10 +31,12 @@ out += [ "use anyhow::{bail, Result};", + "use num_traits::FromPrimitive;", + "use spirq_core::spirv::Op;", "", - "", - "fn unknown_operand_index(i: usize) -> Result<&'static str> {", - ' bail!("Unknown operand index: {}", i)', + "fn unknown_operand_index(opcode: u32, i: usize) -> Result<&'static str> {", + ' let opname = Op::from_u32(opcode).map(|op| format!("{:?}", op)).unwrap_or("".to_owned());', + ' bail!("Unknown op {} ({}) operand index: {}", opname, opcode, i)', "}", "", "pub fn operand_enum_type(opcode: u32, i: usize) -> Result<&'static str> {", @@ -53,8 +55,8 @@ f' {i} => "{kind}",', ] out += [ - " _ => return unknown_operand_index(i),", - " }", + " _ => return unknown_operand_index(opcode, i),", + " },", ] out += [ diff --git a/spirq-spvasm/src/generated/operand_enum_type.rs b/spirq-spvasm/src/generated/operand_enum_type.rs index a773f10..7c53f72 100644 --- a/spirq-spvasm/src/generated/operand_enum_type.rs +++ b/spirq-spvasm/src/generated/operand_enum_type.rs @@ -1,432 +1,435 @@ use anyhow::{bail, Result}; +use num_traits::FromPrimitive; +use spirq_core::spirv::Op; -fn unknown_operand_index(i: usize) -> Result<&'static str> { - bail!("Unknown operand index: {}", i) +fn unknown_operand_index(opcode: u32, i: usize) -> Result<&'static str> { + let opname = Op::from_u32(opcode).map(|op| format!("{:?}", op)).unwrap_or("".to_owned()); + bail!("Unknown op {} ({}) operand index: {}", opname, opcode, i) } pub fn operand_enum_type(opcode: u32, i: usize) -> Result<&'static str> { let out: &'static str = match opcode { 3 => match i { 0 => "SourceLanguage", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 14 => match i { 0 => "AddressingModel", 1 => "MemoryModel", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 15 => match i { 0 => "ExecutionModel", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 16 => match i { 1 => "ExecutionMode", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 17 => match i { 0 => "Capability", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 25 => match i { 1 => "Dim", 6 => "ImageFormat", 7 => "AccessQualifier", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 32 => match i { 0 => "StorageClass", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 38 => match i { 0 => "AccessQualifier", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 39 => match i { 1 => "StorageClass", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 45 => match i { 0 => "SamplerAddressingMode", 2 => "SamplerFilterMode", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 54 => match i { 0 => "FunctionControl", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 59 => match i { 0 => "StorageClass", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 61 => match i { 1 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 62 => match i { 2 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 63 => match i { 2 => "MemoryAccess", 3 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 64 => match i { 3 => "MemoryAccess", 4 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 71 => match i { 1 => "Decoration", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 72 => match i { 2 => "Decoration", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 87 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 88 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 89 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 90 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 91 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 92 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 93 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 94 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 95 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 96 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 97 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 98 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 99 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 123 => match i { 1 => "StorageClass", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 246 => match i { 2 => "LoopControl", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 247 => match i { 1 => "SelectionControl", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 264 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 265 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 266 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 267 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 268 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 269 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 270 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 271 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 305 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 306 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 307 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 308 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 309 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 310 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 311 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 312 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 313 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 314 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 315 => match i { 3 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 320 => match i { 2 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 331 => match i { 1 => "ExecutionMode", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 332 => match i { 1 => "Decoration", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 342 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 349 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 350 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 351 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 352 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 353 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 354 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 355 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 356 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 357 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 358 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 359 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 360 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 361 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 362 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 363 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 364 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4450 => match i { 2 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4451 => match i { 2 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4452 => match i { 2 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4453 => match i { 3 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4454 => match i { 3 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4455 => match i { 3 => "PackedVectorFormat", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4457 => match i { 3 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4458 => match i { 4 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 4459 => match i { 3 => "CooperativeMatrixOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5000 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5001 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5002 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5003 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5004 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5005 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5006 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5007 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5283 => match i { 4 => "ImageOperands", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5359 => match i { 3 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5360 => match i { 4 => "MemoryAccess", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5632 => match i { 1 => "Decoration", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 5633 => match i { 2 => "Decoration", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6086 => match i { 0 => "AccessQualifier", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6401 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6402 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6403 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6404 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6405 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6406 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6407 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, 6408 => match i { 1 => "GroupOperation", - _ => return unknown_operand_index(i), + _ => return unknown_operand_index(opcode, i), }, _ => bail!("{}-th operand of opcode {} is not a enum", i, opcode), }; From 7b0fc608917619207e7f49bc4272d9bd0eee6d3f Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 13 Feb 2024 13:48:53 +0800 Subject: [PATCH 2/3] Fix decoration parsing in spirq-spvasm --- Cargo.lock | 6 +- .../generated/decorate_parameter_enum_type.rs | 158 +++++++++++------- spirq-spvasm/src/generated/mod.rs | 2 + 3 files changed, 99 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3bb2ecd..c8430d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -402,7 +402,7 @@ dependencies = [ [[package]] name = "spirq-as" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "clap", @@ -424,7 +424,7 @@ dependencies = [ [[package]] name = "spirq-dis" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "clap", @@ -433,7 +433,7 @@ dependencies = [ [[package]] name = "spirq-spvasm" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "half", diff --git a/spirq-spvasm/src/generated/decorate_parameter_enum_type.rs b/spirq-spvasm/src/generated/decorate_parameter_enum_type.rs index 65fd2e9..f7bede8 100644 --- a/spirq-spvasm/src/generated/decorate_parameter_enum_type.rs +++ b/spirq-spvasm/src/generated/decorate_parameter_enum_type.rs @@ -1,4 +1,4 @@ -use anyhow::{bail, Result}; +use anyhow::{ bail, Result }; use num_traits::FromPrimitive; use spirq_core::spirv::Op; @@ -6,73 +6,103 @@ fn unknown_decorate_parameter_index(decoration: u32, i: usize) -> Result<&'stati let opname = Op::from_u32(decoration) .map(|op| format!("{:?}", op)) .unwrap_or("".to_owned()); - bail!( - "Unknown op {} ({}) parameter index: {}", - opname, - decoration, - i - ) + bail!("Unknown op {} ({}) parameter index: {}", opname, decoration, i) } pub fn decorate_parameter_enum_type(decoration: u32, i: usize) -> Result<&'static str> { let out: &'static str = match decoration { - 11 => match i { - 0 => "BuiltIn", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 38 => match i { - 0 => "FunctionParameterAttribute", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 39 => match i { - 0 => "FPRoundingMode", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 40 => match i { - 0 => "FPFastMathMode", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 41 => match i { - 1 => "LinkageType", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 5822 => match i { - 1 => "FPRoundingMode", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 5823 => match i { - 1 => "FPDenormMode", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6080 => match i { - 1 => "FPOperationMode", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6180 => match i { - 0 => "AccessQualifier", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6188 => match i { - 0 => "HostAccessQualifier", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6190 => match i { - 0 => "InitializationModeQualifier", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6442 => match i { - 1 => "LoadCacheControl", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - 6443 => match i { - 1 => "StoreCacheControl", - _ => return unknown_decorate_parameter_index(decoration, i), - }, - _ => bail!( - "{}-th parameter of decoration {} is not a enum", - i, - decoration - ), + 11 => + match i { + 0 => "BuiltIn", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 38 => + match i { + 0 => "FunctionParameterAttribute", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 39 => + match i { + 0 => "FPRoundingMode", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 40 => + match i { + 0 => "FPFastMathMode", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 41 => + match i { + 1 => "LinkageType", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 5822 => + match i { + 1 => "FPRoundingMode", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 5823 => + match i { + 1 => "FPDenormMode", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6080 => + match i { + 1 => "FPOperationMode", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6180 => + match i { + 0 => "AccessQualifier", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6188 => + match i { + 0 => "HostAccessQualifier", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6190 => + match i { + 0 => "InitializationModeQualifier", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6442 => + match i { + 1 => "LoadCacheControl", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + 6443 => + match i { + 1 => "StoreCacheControl", + _ => { + return unknown_decorate_parameter_index(decoration, i); + } + } + _ => bail!("{}-th parameter of decoration {} is not a enum", i, decoration), }; Ok(out) } diff --git a/spirq-spvasm/src/generated/mod.rs b/spirq-spvasm/src/generated/mod.rs index 026d693..d5359eb 100644 --- a/spirq-spvasm/src/generated/mod.rs +++ b/spirq-spvasm/src/generated/mod.rs @@ -7,6 +7,7 @@ mod op_has_result_type_id; mod op_to_str; mod operand_enum_type; mod print_operand; +mod decorate_parameter_enum_type; pub use decorate_parameter_enum_type::decorate_parameter_enum_type; pub use enum_from_str::enum_from_str; @@ -17,3 +18,4 @@ pub use op_has_result_type_id::op_has_result_type_id; pub use op_to_str::op_to_str; pub use operand_enum_type::operand_enum_type; pub use print_operand::print_operand; +pub use decorate_parameter_enum_type::decorate_parameter_enum_type; From 251c0a69c1c1a24deb7ec6cd874ad5f5cdb54b2b Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 13 Feb 2024 14:06:56 +0800 Subject: [PATCH 3/3] x --- Cargo.lock | 60 ++++++++++++++++++++++++++++++++++++++-------- spirq/Cargo.toml | 2 +- spirq/src/tests.rs | 37 ++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c8430d3..5102c01 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -168,13 +168,12 @@ dependencies = [ [[package]] name = "inline-spirv" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9053387c6399d5186b89157b38dc4a923e6759440769bef1b03881ada343f24a" +version = "0.2.0" dependencies = [ "quote", "shaderc", - "syn 1.0.107", + "spirq-spvasm 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 2.0.27", ] [[package]] @@ -363,7 +362,7 @@ dependencies = [ "serde", "serde_json", "shaderc", - "spirq", + "spirq 1.1.1", ] [[package]] @@ -397,7 +396,20 @@ dependencies = [ "num-derive", "num-traits", "ordered-float", - "spirq-core", + "spirq-core 1.0.2", +] + +[[package]] +name = "spirq" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d3d533a07dc68fbbe7bb156011d2ae627481d43c915b41dd999b257cb100ca7" +dependencies = [ + "fnv", + "num-derive", + "num-traits", + "ordered-float", + "spirq-core 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -406,7 +418,7 @@ version = "0.1.3" dependencies = [ "anyhow", "clap", - "spirq-spvasm", + "spirq-spvasm 0.1.3", ] [[package]] @@ -422,13 +434,28 @@ dependencies = [ "spirv", ] +[[package]] +name = "spirq-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "647d3ae16263e7c6ebef89bb3e1fd6433003b1a28a37f47e8f1b7cf24ee16faf" +dependencies = [ + "anyhow", + "bytemuck", + "fnv", + "half", + "num-traits", + "ordered-float", + "spirv", +] + [[package]] name = "spirq-dis" version = "0.1.3" dependencies = [ "anyhow", "clap", - "spirq-spvasm", + "spirq-spvasm 0.1.3", ] [[package]] @@ -439,8 +466,21 @@ dependencies = [ "half", "num-traits", "pretty_assertions", - "spirq", - "spirq-core", + "spirq 1.1.1", + "spirq-core 1.0.2", +] + +[[package]] +name = "spirq-spvasm" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "649660d5b8b7dc158eb4597c79ea5f85cd0bd3014f1d961d2dafccdec59b0561" +dependencies = [ + "anyhow", + "half", + "num-traits", + "spirq 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "spirq-core 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] diff --git a/spirq/Cargo.toml b/spirq/Cargo.toml index 9ec9e10..b72d56d 100644 --- a/spirq/Cargo.toml +++ b/spirq/Cargo.toml @@ -27,4 +27,4 @@ ordered-float = "3.4.0" [dev-dependencies] bytes = "1.2" byteorder = "1.3" -inline-spirv = "0.1" +inline-spirv = { version = "0.2", path = "../../inline-spirv/inline-spirv" } diff --git a/spirq/src/tests.rs b/spirq/src/tests.rs index 61858ff..1b51d8a 100644 --- a/spirq/src/tests.rs +++ b/spirq/src/tests.rs @@ -722,3 +722,40 @@ fn test_resource_in_chained_call() { // Ensure the unreferenced one is not in the map. assert_eq!(desc_binds.get(&DescriptorBinding::new(1, 3)), None); } + +#[test] +fn test_issue_124() { + inline_spirv!(r#" + OpCapability Shader + OpExtension "SPV_GOOGLE_hlsl_functionality1" + OpMemoryModel Logical GLSL450 + OpEntryPoint Vertex %vert "vert" %in_var_POSITION %gl_Position + OpDecorateString %in_var_POSITION UserSemantic "POSITION" + OpDecorate %gl_Position BuiltIn Position + OpDecorateString %gl_Position UserSemantic "SV_POSITION" + OpDecorate %in_var_POSITION Location 0 +%float = OpTypeFloat 32 +%v4float = OpTypeVector %float 4 +%_ptr_Input_v4float = OpTypePointer Input %v4float +%_ptr_Output_v4float = OpTypePointer Output %v4float +%void = OpTypeVoid +%10 = OpTypeFunction %void +%in_var_POSITION = OpVariable %_ptr_Input_v4float Input +%gl_Position = OpVariable %_ptr_Output_v4float Output +%vert = OpFunction %void None %10 +%11 = OpLabel +%12 = OpLoad %v4float %in_var_POSITION + OpStore %gl_Position %12 + OpReturn + OpFunctionEnd +"#, spvasm); + let entry = ReflectConfig::new() + .spv(SPV) + .ref_all_rscs(true) + .reflect() + .unwrap() + .pop() + .unwrap(); + + +}