1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_shader_tokens.h"
34 #if defined __cplusplus
38 struct tgsi_full_header
40 struct tgsi_header Header
;
41 struct tgsi_processor Processor
;
44 struct tgsi_full_dst_register
46 struct tgsi_dst_register Register
;
47 struct tgsi_src_register Indirect
;
48 struct tgsi_dimension Dimension
;
49 struct tgsi_src_register DimIndirect
;
52 struct tgsi_full_src_register
54 struct tgsi_src_register Register
;
55 struct tgsi_src_register Indirect
;
56 struct tgsi_dimension Dimension
;
57 struct tgsi_src_register DimIndirect
;
60 struct tgsi_immediate_array_data
62 union tgsi_immediate_data
*u
;
65 struct tgsi_full_declaration
67 struct tgsi_declaration Declaration
;
68 struct tgsi_declaration_range Range
;
69 struct tgsi_declaration_dimension Dim
;
70 struct tgsi_declaration_semantic Semantic
;
71 struct tgsi_immediate_array_data ImmediateData
;
72 struct tgsi_declaration_resource Resource
;
73 struct tgsi_declaration_sampler_view SamplerView
;
76 struct tgsi_full_immediate
78 struct tgsi_immediate Immediate
;
79 union tgsi_immediate_data u
[4];
82 struct tgsi_full_property
84 struct tgsi_property Property
;
85 struct tgsi_property_data u
[8];
88 #define TGSI_FULL_MAX_DST_REGISTERS 2
89 #define TGSI_FULL_MAX_SRC_REGISTERS 5 /* SAMPLE_D has 5 */
90 #define TGSI_FULL_MAX_TEX_OFFSETS 4
92 struct tgsi_full_instruction
94 struct tgsi_instruction Instruction
;
95 struct tgsi_instruction_predicate Predicate
;
96 struct tgsi_instruction_label Label
;
97 struct tgsi_instruction_texture Texture
;
98 struct tgsi_full_dst_register Dst
[TGSI_FULL_MAX_DST_REGISTERS
];
99 struct tgsi_full_src_register Src
[TGSI_FULL_MAX_SRC_REGISTERS
];
100 struct tgsi_texture_offset TexOffsets
[TGSI_FULL_MAX_TEX_OFFSETS
];
103 union tgsi_full_token
105 struct tgsi_token Token
;
106 struct tgsi_full_declaration FullDeclaration
;
107 struct tgsi_full_immediate FullImmediate
;
108 struct tgsi_full_instruction FullInstruction
;
109 struct tgsi_full_property FullProperty
;
112 struct tgsi_parse_context
114 const struct tgsi_token
*Tokens
;
116 struct tgsi_full_header FullHeader
;
117 union tgsi_full_token FullToken
;
120 #define TGSI_PARSE_OK 0
121 #define TGSI_PARSE_ERROR 1
125 struct tgsi_parse_context
*ctx
,
126 const struct tgsi_token
*tokens
);
130 struct tgsi_parse_context
*ctx
);
133 tgsi_parse_end_of_tokens(
134 struct tgsi_parse_context
*ctx
);
138 struct tgsi_parse_context
*ctx
);
140 static INLINE
unsigned
141 tgsi_num_tokens(const struct tgsi_token
*tokens
)
143 struct tgsi_header header
;
144 memcpy(&header
, tokens
, sizeof(header
));
145 return header
.HeaderSize
+ header
.BodySize
;
149 tgsi_dump_tokens(const struct tgsi_token
*tokens
);
152 tgsi_dup_tokens(const struct tgsi_token
*tokens
);
155 tgsi_alloc_tokens(unsigned num_tokens
);
158 #if defined __cplusplus
162 #endif /* TGSI_PARSE_H */