Skip to main content

ptx_parser/unparser/instruction/
txq.rs

1//! Original PTX specification:
2//!
3//! txq.tquery.b32         d, [a];       // texture attributes
4//! txq.level.tlquery.b32  d, [a], lod;  // texture attributes
5//! txq.squery.b32         d, [a];       // sampler attributes
6//! .tquery  = { .width, .height, .depth,
7//! .channel_data_type, .channel_order,
8//! .normalized_coords, .array_size,
9//! .num_mipmap_levels, .num_samples};
10//! .tlquery = { .width, .height, .depth };
11//! .squery  = { .force_unnormalized_coords, .filter_mode,
12//! .addr_mode_0, addr_mode_1, addr_mode_2 };
13
14#![allow(unused)]
15
16use crate::lexer::PtxToken;
17use crate::unparser::{PtxUnparser, common::*};
18
19pub mod section_0 {
20    use super::*;
21    use crate::r#type::instruction::txq::section_0::*;
22
23    impl PtxUnparser for TxqTqueryB32 {
24        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
25            self.unparse_tokens_mode(tokens, false);
26        }
27        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
28            push_opcode(tokens, "txq");
29            match &self.tquery {
30                Tquery::ChannelDataType => {
31                    push_directive(tokens, "channel_data_type");
32                }
33                Tquery::NormalizedCoords => {
34                    push_directive(tokens, "normalized_coords");
35                }
36                Tquery::NumMipmapLevels => {
37                    push_directive(tokens, "num_mipmap_levels");
38                }
39                Tquery::ChannelOrder => {
40                    push_directive(tokens, "channel_order");
41                }
42                Tquery::NumSamples => {
43                    push_directive(tokens, "num_samples");
44                }
45                Tquery::ArraySize => {
46                    push_directive(tokens, "array_size");
47                }
48                Tquery::Height => {
49                    push_directive(tokens, "height");
50                }
51                Tquery::Width => {
52                    push_directive(tokens, "width");
53                }
54                Tquery::Depth => {
55                    push_directive(tokens, "depth");
56                }
57            }
58            push_directive(tokens, "b32");
59            if spaced {
60                tokens.push(PtxToken::Space);
61            }
62            self.d.unparse_tokens_mode(tokens, spaced);
63            tokens.push(PtxToken::Comma);
64            if spaced {
65                tokens.push(PtxToken::Space);
66            }
67            self.a.unparse_tokens_mode(tokens, spaced);
68            tokens.push(PtxToken::Semicolon);
69            if spaced {
70                tokens.push(PtxToken::Newline);
71            }
72        }
73    }
74
75    impl PtxUnparser for TxqLevelTlqueryB32 {
76        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
77            self.unparse_tokens_mode(tokens, false);
78        }
79        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
80            push_opcode(tokens, "txq");
81            push_directive(tokens, "level");
82            match &self.tlquery {
83                Tlquery::Height => {
84                    push_directive(tokens, "height");
85                }
86                Tlquery::Width => {
87                    push_directive(tokens, "width");
88                }
89                Tlquery::Depth => {
90                    push_directive(tokens, "depth");
91                }
92            }
93            push_directive(tokens, "b32");
94            if spaced {
95                tokens.push(PtxToken::Space);
96            }
97            self.d.unparse_tokens_mode(tokens, spaced);
98            tokens.push(PtxToken::Comma);
99            if spaced {
100                tokens.push(PtxToken::Space);
101            }
102            self.a.unparse_tokens_mode(tokens, spaced);
103            tokens.push(PtxToken::Comma);
104            if spaced {
105                tokens.push(PtxToken::Space);
106            }
107            self.lod.unparse_tokens_mode(tokens, spaced);
108            tokens.push(PtxToken::Semicolon);
109            if spaced {
110                tokens.push(PtxToken::Newline);
111            }
112        }
113    }
114
115    impl PtxUnparser for TxqSqueryB32 {
116        fn unparse_tokens(&self, tokens: &mut ::std::vec::Vec<PtxToken>) {
117            self.unparse_tokens_mode(tokens, false);
118        }
119        fn unparse_tokens_mode(&self, tokens: &mut ::std::vec::Vec<PtxToken>, spaced: bool) {
120            push_opcode(tokens, "txq");
121            match &self.squery {
122                Squery::ForceUnnormalizedCoords => {
123                    push_directive(tokens, "force_unnormalized_coords");
124                }
125                Squery::FilterMode => {
126                    push_directive(tokens, "filter_mode");
127                }
128                Squery::AddrMode0 => {
129                    push_directive(tokens, "addr_mode_0");
130                }
131                Squery::AddrMode1 => {
132                    push_token_from_str(tokens, "addr_mode_1");
133                }
134                Squery::AddrMode2 => {
135                    push_token_from_str(tokens, "addr_mode_2");
136                }
137            }
138            push_directive(tokens, "b32");
139            if spaced {
140                tokens.push(PtxToken::Space);
141            }
142            self.d.unparse_tokens_mode(tokens, spaced);
143            tokens.push(PtxToken::Comma);
144            if spaced {
145                tokens.push(PtxToken::Space);
146            }
147            self.a.unparse_tokens_mode(tokens, spaced);
148            tokens.push(PtxToken::Semicolon);
149            if spaced {
150                tokens.push(PtxToken::Newline);
151            }
152        }
153    }
154}