@@ -14,18 +14,17 @@ impl Display for PixelBenderShaderDisassembly<'_> {
1414 fn fmt ( & self , f : & mut Formatter < ' _ > ) -> std:: fmt:: Result {
1515 writeln ! (
1616 f,
17- "{} {}" ,
17+ "{} {}i " ,
1818 self . opcode_to_str( Opcode :: Version ) ,
1919 self . 0 . version,
2020 ) ?;
2121 writeln ! ( f, "{} {:?}" , self . opcode_to_str( Opcode :: Name ) , self . 0 . name) ?;
2222 writeln ! ( f) ?;
23- self . fmt_metadata ( f, & self . 0 . metadata , "" ) ?;
23+ self . fmt_metadata ( f, & self . 0 . metadata ) ?;
2424 if !self . 0 . metadata . is_empty ( ) {
2525 writeln ! ( f) ?;
2626 }
2727 self . fmt_parameters ( f) ?;
28- writeln ! ( f) ?;
2928 self . fmt_operations ( f) ?;
3029 Ok ( ( ) )
3130 }
@@ -36,10 +35,14 @@ impl PixelBenderShaderDisassembly<'_> {
3635 & self ,
3736 f : & mut Formatter < ' _ > ,
3837 metadata : & Vec < PixelBenderMetadata > ,
39- prefix : & str ,
4038 ) -> std:: fmt:: Result {
4139 for meta in metadata {
42- write ! ( f, "{prefix}meta {:?} " , meta. key) ?;
40+ let opcode = self . opcode_to_str ( if meta. is_meta2 {
41+ Opcode :: PBJMeta2
42+ } else {
43+ Opcode :: PBJMeta1
44+ } ) ;
45+ write ! ( f, "{} {:?}, " , opcode, meta. key) ?;
4346 self . fmt_type ( f, & meta. value ) ?;
4447 writeln ! ( f) ?;
4548 }
@@ -60,17 +63,12 @@ impl PixelBenderShaderDisassembly<'_> {
6063 let param_type = self . type_to_str ( * param_type) ;
6164 write ! (
6265 f,
63- "{} {qualifier} {name:?} {param_type} " ,
66+ "{}. {qualifier} {name:?}, {param_type}, " ,
6467 self . opcode_to_str( Opcode :: PBJParam )
6568 ) ?;
6669 self . fmt_reg ( f, reg) ?;
67- if metadata. is_empty ( ) {
68- writeln ! ( f) ?;
69- } else {
70- writeln ! ( f, " {{" ) ?;
71- self . fmt_metadata ( f, metadata, " " ) ?;
72- writeln ! ( f, "}}" ) ?;
73- }
70+ writeln ! ( f) ?;
71+ self . fmt_metadata ( f, metadata) ?;
7472 }
7573 PixelBenderParam :: Texture {
7674 index,
@@ -79,11 +77,12 @@ impl PixelBenderShaderDisassembly<'_> {
7977 } => {
8078 writeln ! (
8179 f,
82- "{} {name:?} {index} {channels}" ,
80+ "{} {name:?}, {index}i, {channels}i " ,
8381 self . opcode_to_str( Opcode :: PBJParamTexture )
8482 ) ?;
8583 }
8684 }
85+ writeln ! ( f) ?;
8786 }
8887 Ok ( ( ) )
8988 }
@@ -108,22 +107,28 @@ impl PixelBenderShaderDisassembly<'_> {
108107
109108 fn fmt_type ( & self , f : & mut Formatter < ' _ > , type_ : & PixelBenderType ) -> std:: fmt:: Result {
110109 match type_ {
111- PixelBenderType :: TFloat ( a) => write ! ( f, "float({a})" ) ,
112- PixelBenderType :: TFloat2 ( a, b) => write ! ( f, "float2({a}, {b})" ) ,
113- PixelBenderType :: TFloat3 ( a, b, c) => write ! ( f, "float3({a}, {b}, {c})" ) ,
114- PixelBenderType :: TFloat4 ( a, b, c, d) => write ! ( f, "float4({a}, {b}, {c}, {d})" ) ,
115- PixelBenderType :: TFloat2x2 ( a) => write ! ( f, "float2x2({a:?})" ) ,
116- PixelBenderType :: TFloat3x3 ( a) => write ! ( f, "float3x3({a:?})" ) ,
117- PixelBenderType :: TFloat4x4 ( a) => write ! ( f, "float4x4({a:?})" ) ,
118- PixelBenderType :: TInt ( a) => write ! ( f, "int({a})" ) ,
119- PixelBenderType :: TInt2 ( a, b) => write ! ( f, "int2({a}, {b})" ) ,
120- PixelBenderType :: TInt3 ( a, b, c) => write ! ( f, "int3({a}, {b}, {c})" ) ,
121- PixelBenderType :: TInt4 ( a, b, c, d) => write ! ( f, "int4({a}, {b}, {c}, {d})" ) ,
110+ PixelBenderType :: TFloat ( a) => write ! ( f, "float({a}f)" ) ,
111+ PixelBenderType :: TFloat2 ( a, b) => write ! ( f, "float2({a}f, {b}f)" ) ,
112+ PixelBenderType :: TFloat3 ( a, b, c) => write ! ( f, "float3({a}f, {b}f, {c}f)" ) ,
113+ PixelBenderType :: TFloat4 ( a, b, c, d) => write ! ( f, "float4({a}f, {b}f, {c}f, {d}f)" ) ,
114+ PixelBenderType :: TFloat2x2 ( v) => {
115+ write ! ( f, "float2x2({}f)" , v. map( |v| v. to_string( ) ) . join( "f, " ) )
116+ }
117+ PixelBenderType :: TFloat3x3 ( v) => {
118+ write ! ( f, "float3x3({}f)" , v. map( |v| v. to_string( ) ) . join( "f, " ) )
119+ }
120+ PixelBenderType :: TFloat4x4 ( v) => {
121+ write ! ( f, "float4x4({}f)" , v. map( |v| v. to_string( ) ) . join( "f, " ) )
122+ }
123+ PixelBenderType :: TInt ( a) => write ! ( f, "int({a}i)" ) ,
124+ PixelBenderType :: TInt2 ( a, b) => write ! ( f, "int2({a}i, {b}i)" ) ,
125+ PixelBenderType :: TInt3 ( a, b, c) => write ! ( f, "int3({a}i, {b}i, {c}i)" ) ,
126+ PixelBenderType :: TInt4 ( a, b, c, d) => write ! ( f, "int4({a}i, {b}i, {c}i, {d}i)" ) ,
122127 PixelBenderType :: TString ( a) => write ! ( f, "string({a:?})" ) ,
123- PixelBenderType :: TBool ( a) => write ! ( f, "bool({a})" ) ,
124- PixelBenderType :: TBool2 ( a, b) => write ! ( f, "bool2({a}, {b})" ) ,
125- PixelBenderType :: TBool3 ( a, b, c) => write ! ( f, "bool3({a}, {b}, {c})" ) ,
126- PixelBenderType :: TBool4 ( a, b, c, d) => write ! ( f, "bool4({a}, {b}, {c}, {d})" ) ,
128+ PixelBenderType :: TBool ( a) => write ! ( f, "bool({a}i )" ) ,
129+ PixelBenderType :: TBool2 ( a, b) => write ! ( f, "bool2({a}i , {b}i )" ) ,
130+ PixelBenderType :: TBool3 ( a, b, c) => write ! ( f, "bool3({a}i , {b}i , {c}i )" ) ,
131+ PixelBenderType :: TBool4 ( a, b, c, d) => write ! ( f, "bool4({a}i , {b}i , {c}i , {d}i )" ) ,
127132 }
128133 }
129134
@@ -144,41 +149,57 @@ impl PixelBenderShaderDisassembly<'_> {
144149 match op {
145150 Operation :: Nop => writeln ! ( f, "{prefix}{}" , self . opcode_to_str( Opcode :: Nop ) ) ?,
146151 Operation :: Normal { opcode, dst, src } => {
147- write ! ( f, "{prefix}{} \t " , self . opcode_to_str( * opcode) ) ?;
152+ write ! ( f, "{prefix}{:<7} " , self . opcode_to_str( * opcode) ) ?;
148153 self . fmt_reg ( f, dst) ?;
149154 write ! ( f, ", " ) ?;
150155 self . fmt_reg ( f, src) ?;
151156 writeln ! ( f) ?;
152157 }
153158 Operation :: LoadInt { dst, val } => {
154- write ! ( f, "{prefix}ld.i\t " ) ?;
159+ write ! (
160+ f,
161+ "{prefix}{:<7} " ,
162+ self . opcode_to_str( Opcode :: LoadIntOrFloat )
163+ ) ?;
155164 self . fmt_reg ( f, dst) ?;
156- writeln ! ( f, ", {val}" ) ?;
165+ writeln ! ( f, ", {val}i " ) ?;
157166 }
158167 Operation :: LoadFloat { dst, val } => {
159- write ! ( f, "{prefix}ld.f\t " ) ?;
168+ write ! (
169+ f,
170+ "{prefix}{:<7} " ,
171+ self . opcode_to_str( Opcode :: LoadIntOrFloat )
172+ ) ?;
160173 self . fmt_reg ( f, dst) ?;
161- writeln ! ( f, ", {val}" ) ?;
174+ writeln ! ( f, ", {val}f " ) ?;
162175 }
163176 Operation :: If { src } => {
164- write ! ( f, "{prefix}{} \t " , self . opcode_to_str( Opcode :: If ) ) ?;
177+ write ! ( f, "{prefix}{:<7} " , self . opcode_to_str( Opcode :: If ) ) ?;
165178 self . fmt_reg ( f, src) ?;
166179 writeln ! ( f) ?;
167180 self . prefix_inc ( prefix) ;
168181 }
169182 Operation :: SampleNearest { dst, src, tf } => {
170- write ! ( f, "{prefix}{}\t " , self . opcode_to_str( Opcode :: SampleNearest ) ) ?;
183+ write ! (
184+ f,
185+ "{prefix}{:<7} " ,
186+ self . opcode_to_str( Opcode :: SampleNearest )
187+ ) ?;
171188 self . fmt_reg ( f, dst) ?;
172189 write ! ( f, ", " ) ?;
173190 self . fmt_reg ( f, src) ?;
174- writeln ! ( f, ", {tf}" ) ?;
191+ writeln ! ( f, ", {tf}i " ) ?;
175192 }
176193 Operation :: SampleLinear { dst, src, tf } => {
177- write ! ( f, "{prefix}{}\t " , self . opcode_to_str( Opcode :: SampleLinear ) ) ?;
194+ write ! (
195+ f,
196+ "{prefix}{:<7} " ,
197+ self . opcode_to_str( Opcode :: SampleLinear )
198+ ) ?;
178199 self . fmt_reg ( f, dst) ?;
179200 write ! ( f, ", " ) ?;
180201 self . fmt_reg ( f, src) ?;
181- writeln ! ( f, ", {tf}" ) ?;
202+ writeln ! ( f, ", {tf}i " ) ?;
182203 }
183204 Operation :: Else => {
184205 self . prefix_dec ( prefix) ;
@@ -195,14 +216,14 @@ impl PixelBenderShaderDisassembly<'_> {
195216 condition,
196217 dst,
197218 } => {
198- write ! ( f, "{prefix}{}\t " , self . opcode_to_str( Opcode :: Select ) ) ?;
199- self . fmt_reg ( f, src1) ?;
200- write ! ( f, ", " ) ?;
201- self . fmt_reg ( f, src2) ?;
219+ write ! ( f, "{prefix}{:<7} " , self . opcode_to_str( Opcode :: Select ) ) ?;
220+ self . fmt_reg ( f, dst) ?;
202221 write ! ( f, ", " ) ?;
203222 self . fmt_reg ( f, condition) ?;
204223 write ! ( f, ", " ) ?;
205- self . fmt_reg ( f, dst) ?;
224+ self . fmt_reg ( f, src1) ?;
225+ write ! ( f, ", " ) ?;
226+ self . fmt_reg ( f, src2) ?;
206227 writeln ! ( f) ?;
207228 }
208229 }
@@ -302,7 +323,7 @@ impl PixelBenderShaderDisassembly<'_> {
302323 Opcode :: Equal => "eq" ,
303324 Opcode :: NotEqual => "neq" ,
304325 Opcode :: LessThan => "lt" ,
305- Opcode :: LessThanEqual => "lte " ,
326+ Opcode :: LessThanEqual => "le " ,
306327 Opcode :: LogicalNot => "not" ,
307328 Opcode :: LogicalAnd => "and" ,
308329 Opcode :: LogicalOr => "or" ,
@@ -322,10 +343,10 @@ impl PixelBenderShaderDisassembly<'_> {
322343 Opcode :: VectorNotEqual => "neq.v" ,
323344 Opcode :: BoolAny => "any.b" ,
324345 Opcode :: BoolAll => "all.b" ,
325- Opcode :: PBJMeta1 => "meta1 " ,
346+ Opcode :: PBJMeta1 => "meta " ,
326347 Opcode :: PBJParam => "param" ,
327348 Opcode :: PBJMeta2 => "meta2" ,
328- Opcode :: PBJParamTexture => "param_texture " ,
349+ Opcode :: PBJParamTexture => "param.tex " ,
329350 Opcode :: Name => "name" ,
330351 Opcode :: Version => "version" ,
331352 }
0 commit comments