From 266f8d9466d7e8e2f66a241717a3eacb2e8a8810 Mon Sep 17 00:00:00 2001 From: PENGUINLIONG Date: Tue, 26 Dec 2023 10:37:35 +0800 Subject: [PATCH] Fixed test --- spirq-spvasm/src/asm/assembler.rs | 2 ++ spirq-spvasm/src/dis/disassembler.rs | 4 ++-- spirq-spvasm/src/dis/test.rs | 4 ++-- spirq-spvasm/src/test.rs | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/spirq-spvasm/src/asm/assembler.rs b/spirq-spvasm/src/asm/assembler.rs index 60f7e76..dc58024 100644 --- a/spirq-spvasm/src/asm/assembler.rs +++ b/spirq-spvasm/src/asm/assembler.rs @@ -634,6 +634,8 @@ impl Assembler { buf.extend(instr); } + self.bound = self.bound.max(self.next_id); + let mut spv = vec![ 0x07230203, // Magic number header.version, // Version diff --git a/spirq-spvasm/src/dis/disassembler.rs b/spirq-spvasm/src/dis/disassembler.rs index 0ee2cb8..8056d7e 100644 --- a/spirq-spvasm/src/dis/disassembler.rs +++ b/spirq-spvasm/src/dis/disassembler.rs @@ -359,7 +359,7 @@ mod test { let out = Disassembler::new().disassemble(&spv).unwrap(); assert_eq!( out, - "; SPIR-V\n; Version: 1.0\n; Generator: 0; 0\n; Bound: 1\n; Schema: 0" + "; SPIR-V\n; Version: 1.0\n; Generator: 0; 0\n; Bound: 1\n; Schema: 0\n" ); } @@ -375,7 +375,7 @@ mod test { let out = Disassembler::new().disassemble(&spv).unwrap(); assert_eq!( out, - "; SPIR-V\n; Version: 1.0\n; Generator: 0; 0\n; Bound: 1\n; Schema: 0\nOpNop" + "; SPIR-V\n; Version: 1.0\n; Generator: 0; 0\n; Bound: 1\n; Schema: 0\nOpNop\n" ); } } diff --git a/spirq-spvasm/src/dis/test.rs b/spirq-spvasm/src/dis/test.rs index 2f50512..e071b97 100644 --- a/spirq-spvasm/src/dis/test.rs +++ b/spirq-spvasm/src/dis/test.rs @@ -14,8 +14,8 @@ fn test_disassembler() { .unwrap(); let expect = include_str!("../../../assets/gallery.frag.spvasm") .lines() - .map(|x| x.trim()) + .map(|x| x.trim().to_owned() + "\n") .collect::>() - .join("\n"); + .concat(); assert_eq!(expect, spvasm); } diff --git a/spirq-spvasm/src/test.rs b/spirq-spvasm/src/test.rs index 98760cd..9b20c96 100644 --- a/spirq-spvasm/src/test.rs +++ b/spirq-spvasm/src/test.rs @@ -10,7 +10,7 @@ fn test_asm_dis_roundtrip() { ; SPIR-V ; Version: 1.5 ; Generator: 0; 0 -; Bound: 0 +; Bound: 13 ; Schema: 0 %void = OpTypeVoid %void_0 = OpTypeVoid @@ -25,7 +25,7 @@ fn test_asm_dis_roundtrip() { %void_9 = OpTypeVoid %void_10 = OpTypeVoid "# - .trim(); + .trim_start(); let header = SpirvHeader::default(); let spv = Assembler::new().assemble(code, header).unwrap(); let spvasm = Disassembler::new() @@ -42,9 +42,9 @@ fn test_gallery_roundtrip() { // (penguinliong) For some reason our reassembled SPIR-V use less IDs // than the GLSLang output. Workaround here. .skip(5) - .map(|x| x.trim()) + .map(|x| x.trim().to_owned() + "\n") .collect::>() - .join("\n"); + .concat(); let header = SpirvHeader::new(0x00010500, 0x0008000b); let spv = Assembler::new().assemble(&code, header).unwrap(); let spvasm = Disassembler::new()