1 /**************************************************************************
3 * Copyright 2009-2010 VMware, Inc.
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 VMWARE, INC 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 **************************************************************************/
29 #include "pipe/p_context.h"
30 #include "pipe/p_state.h"
31 #include "tgsi/tgsi_ureg.h"
32 #include "tgsi/tgsi_build.h"
33 #include "tgsi/tgsi_info.h"
34 #include "tgsi/tgsi_dump.h"
35 #include "tgsi/tgsi_sanity.h"
36 #include "util/u_debug.h"
37 #include "util/u_memory.h"
38 #include "util/u_math.h"
39 #include "util/u_bitmask.h"
41 union tgsi_any_token
{
42 struct tgsi_header header
;
43 struct tgsi_processor processor
;
44 struct tgsi_token token
;
45 struct tgsi_property prop
;
46 struct tgsi_property_data prop_data
;
47 struct tgsi_declaration decl
;
48 struct tgsi_declaration_range decl_range
;
49 struct tgsi_declaration_dimension decl_dim
;
50 struct tgsi_declaration_interp decl_interp
;
51 struct tgsi_declaration_semantic decl_semantic
;
52 struct tgsi_declaration_sampler_view decl_sampler_view
;
53 struct tgsi_immediate imm
;
54 union tgsi_immediate_data imm_data
;
55 struct tgsi_instruction insn
;
56 struct tgsi_instruction_predicate insn_predicate
;
57 struct tgsi_instruction_label insn_label
;
58 struct tgsi_instruction_texture insn_texture
;
59 struct tgsi_texture_offset insn_texture_offset
;
60 struct tgsi_src_register src
;
61 struct tgsi_dimension dim
;
62 struct tgsi_dst_register dst
;
68 union tgsi_any_token
*tokens
;
74 #define UREG_MAX_INPUT PIPE_MAX_ATTRIBS
75 #define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS
76 #define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS
77 #define UREG_MAX_CONSTANT_RANGE 32
78 #define UREG_MAX_IMMEDIATE 256
79 #define UREG_MAX_ADDR 2
80 #define UREG_MAX_PRED 1
86 } constant_range
[UREG_MAX_CONSTANT_RANGE
];
87 unsigned nr_constant_ranges
;
96 struct pipe_context
*pipe
;
99 unsigned semantic_name
;
100 unsigned semantic_index
;
102 unsigned char cylindrical_wrap
;
103 unsigned char centroid
;
104 } fs_input
[UREG_MAX_INPUT
];
105 unsigned nr_fs_inputs
;
107 unsigned vs_inputs
[UREG_MAX_INPUT
/32];
111 unsigned semantic_name
;
112 unsigned semantic_index
;
113 } gs_input
[UREG_MAX_INPUT
];
114 unsigned nr_gs_inputs
;
118 unsigned semantic_name
;
119 unsigned semantic_index
;
120 } system_value
[UREG_MAX_SYSTEM_VALUE
];
121 unsigned nr_system_values
;
124 unsigned semantic_name
;
125 unsigned semantic_index
;
126 unsigned usage_mask
; /* = TGSI_WRITEMASK_* */
127 } output
[UREG_MAX_OUTPUT
];
138 } immediate
[UREG_MAX_IMMEDIATE
];
139 unsigned nr_immediates
;
141 struct ureg_src sampler
[PIPE_MAX_SAMPLERS
];
142 unsigned nr_samplers
;
147 unsigned return_type_x
;
148 unsigned return_type_y
;
149 unsigned return_type_z
;
150 unsigned return_type_w
;
151 } sampler_view
[PIPE_MAX_SHADER_SAMPLER_VIEWS
];
152 unsigned nr_sampler_views
;
154 struct util_bitmask
*free_temps
;
157 struct const_decl const_decls
;
158 struct const_decl const_decls2D
[PIPE_MAX_CONSTANT_BUFFERS
];
160 unsigned property_gs_input_prim
;
161 unsigned property_gs_output_prim
;
162 unsigned property_gs_max_vertices
;
163 unsigned char property_fs_coord_origin
; /* = TGSI_FS_COORD_ORIGIN_* */
164 unsigned char property_fs_coord_pixel_center
; /* = TGSI_FS_COORD_PIXEL_CENTER_* */
165 unsigned char property_fs_color0_writes_all_cbufs
; /* = TGSI_FS_COLOR0_WRITES_ALL_CBUFS * */
166 unsigned char property_fs_depth_layout
; /* TGSI_FS_DEPTH_LAYOUT */
170 unsigned nr_instructions
;
172 struct ureg_tokens domain
[2];
175 static union tgsi_any_token error_tokens
[32];
177 static void tokens_error( struct ureg_tokens
*tokens
)
179 if (tokens
->tokens
&& tokens
->tokens
!= error_tokens
)
180 FREE(tokens
->tokens
);
182 tokens
->tokens
= error_tokens
;
183 tokens
->size
= Elements(error_tokens
);
188 static void tokens_expand( struct ureg_tokens
*tokens
,
191 unsigned old_size
= tokens
->size
* sizeof(unsigned);
193 if (tokens
->tokens
== error_tokens
) {
197 while (tokens
->count
+ count
> tokens
->size
) {
198 tokens
->size
= (1 << ++tokens
->order
);
201 tokens
->tokens
= REALLOC(tokens
->tokens
,
203 tokens
->size
* sizeof(unsigned));
204 if (tokens
->tokens
== NULL
) {
205 tokens_error(tokens
);
209 static void set_bad( struct ureg_program
*ureg
)
211 tokens_error(&ureg
->domain
[0]);
216 static union tgsi_any_token
*get_tokens( struct ureg_program
*ureg
,
220 struct ureg_tokens
*tokens
= &ureg
->domain
[domain
];
221 union tgsi_any_token
*result
;
223 if (tokens
->count
+ count
> tokens
->size
)
224 tokens_expand(tokens
, count
);
226 result
= &tokens
->tokens
[tokens
->count
];
227 tokens
->count
+= count
;
232 static union tgsi_any_token
*retrieve_token( struct ureg_program
*ureg
,
236 if (ureg
->domain
[domain
].tokens
== error_tokens
)
237 return &error_tokens
[0];
239 return &ureg
->domain
[domain
].tokens
[nr
];
244 static INLINE
struct ureg_dst
245 ureg_dst_register( unsigned file
,
251 dst
.WriteMask
= TGSI_WRITEMASK_XYZW
;
253 dst
.IndirectIndex
= 0;
254 dst
.IndirectSwizzle
= 0;
258 dst
.PredSwizzleX
= TGSI_SWIZZLE_X
;
259 dst
.PredSwizzleY
= TGSI_SWIZZLE_Y
;
260 dst
.PredSwizzleZ
= TGSI_SWIZZLE_Z
;
261 dst
.PredSwizzleW
= TGSI_SWIZZLE_W
;
269 ureg_property_gs_input_prim(struct ureg_program
*ureg
,
272 ureg
->property_gs_input_prim
= input_prim
;
276 ureg_property_gs_output_prim(struct ureg_program
*ureg
,
277 unsigned output_prim
)
279 ureg
->property_gs_output_prim
= output_prim
;
283 ureg_property_gs_max_vertices(struct ureg_program
*ureg
,
284 unsigned max_vertices
)
286 ureg
->property_gs_max_vertices
= max_vertices
;
290 ureg_property_fs_coord_origin(struct ureg_program
*ureg
,
291 unsigned fs_coord_origin
)
293 ureg
->property_fs_coord_origin
= fs_coord_origin
;
297 ureg_property_fs_coord_pixel_center(struct ureg_program
*ureg
,
298 unsigned fs_coord_pixel_center
)
300 ureg
->property_fs_coord_pixel_center
= fs_coord_pixel_center
;
304 ureg_property_fs_color0_writes_all_cbufs(struct ureg_program
*ureg
,
305 unsigned fs_color0_writes_all_cbufs
)
307 ureg
->property_fs_color0_writes_all_cbufs
= fs_color0_writes_all_cbufs
;
311 ureg_property_fs_depth_layout(struct ureg_program
*ureg
,
312 unsigned fs_depth_layout
)
314 ureg
->property_fs_depth_layout
= fs_depth_layout
;
318 ureg_DECL_fs_input_cyl_centroid(struct ureg_program
*ureg
,
319 unsigned semantic_name
,
320 unsigned semantic_index
,
321 unsigned interp_mode
,
322 unsigned cylindrical_wrap
,
327 for (i
= 0; i
< ureg
->nr_fs_inputs
; i
++) {
328 if (ureg
->fs_input
[i
].semantic_name
== semantic_name
&&
329 ureg
->fs_input
[i
].semantic_index
== semantic_index
) {
334 if (ureg
->nr_fs_inputs
< UREG_MAX_INPUT
) {
335 ureg
->fs_input
[i
].semantic_name
= semantic_name
;
336 ureg
->fs_input
[i
].semantic_index
= semantic_index
;
337 ureg
->fs_input
[i
].interp
= interp_mode
;
338 ureg
->fs_input
[i
].cylindrical_wrap
= cylindrical_wrap
;
339 ureg
->fs_input
[i
].centroid
= centroid
;
340 ureg
->nr_fs_inputs
++;
346 return ureg_src_register(TGSI_FILE_INPUT
, i
);
351 ureg_DECL_vs_input( struct ureg_program
*ureg
,
354 assert(ureg
->processor
== TGSI_PROCESSOR_VERTEX
);
356 ureg
->vs_inputs
[index
/32] |= 1 << (index
% 32);
357 return ureg_src_register( TGSI_FILE_INPUT
, index
);
362 ureg_DECL_gs_input(struct ureg_program
*ureg
,
364 unsigned semantic_name
,
365 unsigned semantic_index
)
367 if (ureg
->nr_gs_inputs
< UREG_MAX_INPUT
) {
368 ureg
->gs_input
[ureg
->nr_gs_inputs
].index
= index
;
369 ureg
->gs_input
[ureg
->nr_gs_inputs
].semantic_name
= semantic_name
;
370 ureg
->gs_input
[ureg
->nr_gs_inputs
].semantic_index
= semantic_index
;
371 ureg
->nr_gs_inputs
++;
376 /* XXX: Add suport for true 2D input registers. */
377 return ureg_src_register(TGSI_FILE_INPUT
, index
);
382 ureg_DECL_system_value(struct ureg_program
*ureg
,
384 unsigned semantic_name
,
385 unsigned semantic_index
)
387 if (ureg
->nr_system_values
< UREG_MAX_SYSTEM_VALUE
) {
388 ureg
->system_value
[ureg
->nr_system_values
].index
= index
;
389 ureg
->system_value
[ureg
->nr_system_values
].semantic_name
= semantic_name
;
390 ureg
->system_value
[ureg
->nr_system_values
].semantic_index
= semantic_index
;
391 ureg
->nr_system_values
++;
396 return ureg_src_register(TGSI_FILE_SYSTEM_VALUE
, index
);
401 ureg_DECL_output_masked( struct ureg_program
*ureg
,
404 unsigned usage_mask
)
408 assert(usage_mask
!= 0);
410 for (i
= 0; i
< ureg
->nr_outputs
; i
++) {
411 if (ureg
->output
[i
].semantic_name
== name
&&
412 ureg
->output
[i
].semantic_index
== index
) {
413 ureg
->output
[i
].usage_mask
|= usage_mask
;
418 if (ureg
->nr_outputs
< UREG_MAX_OUTPUT
) {
419 ureg
->output
[i
].semantic_name
= name
;
420 ureg
->output
[i
].semantic_index
= index
;
421 ureg
->output
[i
].usage_mask
= usage_mask
;
429 return ureg_dst_register( TGSI_FILE_OUTPUT
, i
);
434 ureg_DECL_output( struct ureg_program
*ureg
,
438 return ureg_DECL_output_masked(ureg
, name
, index
, TGSI_WRITEMASK_XYZW
);
442 /* Returns a new constant register. Keep track of which have been
443 * referred to so that we can emit decls later.
445 * Constant operands declared with this function must be addressed
446 * with a two-dimensional index.
448 * There is nothing in this code to bind this constant to any tracked
449 * value or manage any constant_buffer contents -- that's the
450 * resposibility of the calling code.
453 ureg_DECL_constant2D(struct ureg_program
*ureg
,
458 struct const_decl
*decl
= &ureg
->const_decls2D
[index2D
];
460 assert(index2D
< PIPE_MAX_CONSTANT_BUFFERS
);
462 if (decl
->nr_constant_ranges
< UREG_MAX_CONSTANT_RANGE
) {
463 uint i
= decl
->nr_constant_ranges
++;
465 decl
->constant_range
[i
].first
= first
;
466 decl
->constant_range
[i
].last
= last
;
471 /* A one-dimensional, depricated version of ureg_DECL_constant2D().
473 * Constant operands declared with this function must be addressed
474 * with a one-dimensional index.
477 ureg_DECL_constant(struct ureg_program
*ureg
,
480 struct const_decl
*decl
= &ureg
->const_decls
;
481 unsigned minconst
= index
, maxconst
= index
;
484 /* Inside existing range?
486 for (i
= 0; i
< decl
->nr_constant_ranges
; i
++) {
487 if (decl
->constant_range
[i
].first
<= index
&&
488 decl
->constant_range
[i
].last
>= index
) {
493 /* Extend existing range?
495 for (i
= 0; i
< decl
->nr_constant_ranges
; i
++) {
496 if (decl
->constant_range
[i
].last
== index
- 1) {
497 decl
->constant_range
[i
].last
= index
;
501 if (decl
->constant_range
[i
].first
== index
+ 1) {
502 decl
->constant_range
[i
].first
= index
;
506 minconst
= MIN2(minconst
, decl
->constant_range
[i
].first
);
507 maxconst
= MAX2(maxconst
, decl
->constant_range
[i
].last
);
512 if (decl
->nr_constant_ranges
< UREG_MAX_CONSTANT_RANGE
) {
513 i
= decl
->nr_constant_ranges
++;
514 decl
->constant_range
[i
].first
= index
;
515 decl
->constant_range
[i
].last
= index
;
519 /* Collapse all ranges down to one:
522 decl
->constant_range
[0].first
= minconst
;
523 decl
->constant_range
[0].last
= maxconst
;
524 decl
->nr_constant_ranges
= 1;
527 assert(i
< decl
->nr_constant_ranges
);
528 assert(decl
->constant_range
[i
].first
<= index
);
529 assert(decl
->constant_range
[i
].last
>= index
);
530 return ureg_src_register(TGSI_FILE_CONSTANT
, index
);
533 struct ureg_dst
ureg_DECL_temporary( struct ureg_program
*ureg
)
535 /* Look for a released temporary.
537 unsigned i
= util_bitmask_get_first_index(ureg
->free_temps
);
539 /* Or allocate a new one.
541 if (i
== UTIL_BITMASK_INVALID_INDEX
)
542 i
= ureg
->nr_temps
++;
544 util_bitmask_clear(ureg
->free_temps
, i
);
546 return ureg_dst_register( TGSI_FILE_TEMPORARY
, i
);
549 void ureg_release_temporary( struct ureg_program
*ureg
,
550 struct ureg_dst tmp
)
552 if(tmp
.File
== TGSI_FILE_TEMPORARY
)
553 util_bitmask_set(ureg
->free_temps
, tmp
.Index
);
557 /* Allocate a new address register.
559 struct ureg_dst
ureg_DECL_address( struct ureg_program
*ureg
)
561 if (ureg
->nr_addrs
< UREG_MAX_ADDR
)
562 return ureg_dst_register( TGSI_FILE_ADDRESS
, ureg
->nr_addrs
++ );
565 return ureg_dst_register( TGSI_FILE_ADDRESS
, 0 );
568 /* Allocate a new predicate register.
571 ureg_DECL_predicate(struct ureg_program
*ureg
)
573 if (ureg
->nr_preds
< UREG_MAX_PRED
) {
574 return ureg_dst_register(TGSI_FILE_PREDICATE
, ureg
->nr_preds
++);
578 return ureg_dst_register(TGSI_FILE_PREDICATE
, 0);
581 /* Allocate a new sampler.
583 struct ureg_src
ureg_DECL_sampler( struct ureg_program
*ureg
,
588 for (i
= 0; i
< ureg
->nr_samplers
; i
++)
589 if (ureg
->sampler
[i
].Index
== nr
)
590 return ureg
->sampler
[i
];
592 if (i
< PIPE_MAX_SAMPLERS
) {
593 ureg
->sampler
[i
] = ureg_src_register( TGSI_FILE_SAMPLER
, nr
);
595 return ureg
->sampler
[i
];
599 return ureg
->sampler
[0];
603 * Allocate a new shader sampler view.
606 ureg_DECL_sampler_view(struct ureg_program
*ureg
,
609 unsigned return_type_x
,
610 unsigned return_type_y
,
611 unsigned return_type_z
,
612 unsigned return_type_w
)
614 struct ureg_src reg
= ureg_src_register(TGSI_FILE_SAMPLER_VIEW
, index
);
617 for (i
= 0; i
< ureg
->nr_sampler_views
; i
++) {
618 if (ureg
->sampler_view
[i
].index
== index
) {
623 if (i
< PIPE_MAX_SHADER_SAMPLER_VIEWS
) {
624 ureg
->sampler_view
[i
].index
= index
;
625 ureg
->sampler_view
[i
].target
= target
;
626 ureg
->sampler_view
[i
].return_type_x
= return_type_x
;
627 ureg
->sampler_view
[i
].return_type_y
= return_type_y
;
628 ureg
->sampler_view
[i
].return_type_z
= return_type_z
;
629 ureg
->sampler_view
[i
].return_type_w
= return_type_w
;
630 ureg
->nr_sampler_views
++;
639 match_or_expand_immediate( const unsigned *v
,
645 unsigned nr2
= *pnr2
;
650 for (i
= 0; i
< nr
; i
++) {
651 boolean found
= FALSE
;
653 for (j
= 0; j
< nr2
&& !found
; j
++) {
655 *swizzle
|= j
<< (i
* 2);
666 *swizzle
|= nr2
<< (i
* 2);
671 /* Actually expand immediate only when fully succeeded.
678 static struct ureg_src
679 decl_immediate( struct ureg_program
*ureg
,
685 unsigned swizzle
= 0;
687 /* Could do a first pass where we examine all existing immediates
691 for (i
= 0; i
< ureg
->nr_immediates
; i
++) {
692 if (ureg
->immediate
[i
].type
!= type
) {
695 if (match_or_expand_immediate(v
,
697 ureg
->immediate
[i
].value
.u
,
698 &ureg
->immediate
[i
].nr
,
704 if (ureg
->nr_immediates
< UREG_MAX_IMMEDIATE
) {
705 i
= ureg
->nr_immediates
++;
706 ureg
->immediate
[i
].type
= type
;
707 if (match_or_expand_immediate(v
,
709 ureg
->immediate
[i
].value
.u
,
710 &ureg
->immediate
[i
].nr
,
719 /* Make sure that all referenced elements are from this immediate.
720 * Has the effect of making size-one immediates into scalars.
722 for (j
= nr
; j
< 4; j
++) {
723 swizzle
|= (swizzle
& 0x3) << (j
* 2);
726 return ureg_swizzle(ureg_src_register(TGSI_FILE_IMMEDIATE
, i
),
727 (swizzle
>> 0) & 0x3,
728 (swizzle
>> 2) & 0x3,
729 (swizzle
>> 4) & 0x3,
730 (swizzle
>> 6) & 0x3);
735 ureg_DECL_immediate( struct ureg_program
*ureg
,
745 for (i
= 0; i
< nr
; i
++) {
749 return decl_immediate(ureg
, fu
.u
, nr
, TGSI_IMM_FLOAT32
);
754 ureg_DECL_immediate_uint( struct ureg_program
*ureg
,
758 return decl_immediate(ureg
, v
, nr
, TGSI_IMM_UINT32
);
763 ureg_DECL_immediate_block_uint( struct ureg_program
*ureg
,
770 if (ureg
->nr_immediates
+ (nr
+ 3) / 4 > UREG_MAX_IMMEDIATE
) {
772 return ureg_src_register(TGSI_FILE_IMMEDIATE
, 0);
775 index
= ureg
->nr_immediates
;
776 ureg
->nr_immediates
+= (nr
+ 3) / 4;
778 for (i
= index
; i
< ureg
->nr_immediates
; i
++) {
779 ureg
->immediate
[i
].type
= TGSI_IMM_UINT32
;
780 ureg
->immediate
[i
].nr
= nr
> 4 ? 4 : nr
;
781 memcpy(ureg
->immediate
[i
].value
.u
,
783 ureg
->immediate
[i
].nr
* sizeof(uint
));
787 return ureg_src_register(TGSI_FILE_IMMEDIATE
, index
);
792 ureg_DECL_immediate_int( struct ureg_program
*ureg
,
796 return decl_immediate(ureg
, (const unsigned *)v
, nr
, TGSI_IMM_INT32
);
801 ureg_emit_src( struct ureg_program
*ureg
,
802 struct ureg_src src
)
804 unsigned size
= 1 + (src
.Indirect
? 1 : 0) +
805 (src
.Dimension
? (src
.DimIndirect
? 2 : 1) : 0);
807 union tgsi_any_token
*out
= get_tokens( ureg
, DOMAIN_INSN
, size
);
810 assert(src
.File
!= TGSI_FILE_NULL
);
811 assert(src
.File
< TGSI_FILE_COUNT
);
814 out
[n
].src
.File
= src
.File
;
815 out
[n
].src
.SwizzleX
= src
.SwizzleX
;
816 out
[n
].src
.SwizzleY
= src
.SwizzleY
;
817 out
[n
].src
.SwizzleZ
= src
.SwizzleZ
;
818 out
[n
].src
.SwizzleW
= src
.SwizzleW
;
819 out
[n
].src
.Index
= src
.Index
;
820 out
[n
].src
.Negate
= src
.Negate
;
821 out
[0].src
.Absolute
= src
.Absolute
;
825 out
[0].src
.Indirect
= 1;
827 out
[n
].src
.File
= src
.IndirectFile
;
828 out
[n
].src
.SwizzleX
= src
.IndirectSwizzle
;
829 out
[n
].src
.SwizzleY
= src
.IndirectSwizzle
;
830 out
[n
].src
.SwizzleZ
= src
.IndirectSwizzle
;
831 out
[n
].src
.SwizzleW
= src
.IndirectSwizzle
;
832 out
[n
].src
.Index
= src
.IndirectIndex
;
837 if (src
.DimIndirect
) {
838 out
[0].src
.Dimension
= 1;
839 out
[n
].dim
.Indirect
= 1;
840 out
[n
].dim
.Dimension
= 0;
841 out
[n
].dim
.Padding
= 0;
842 out
[n
].dim
.Index
= src
.DimensionIndex
;
845 out
[n
].src
.File
= src
.DimIndFile
;
846 out
[n
].src
.SwizzleX
= src
.DimIndSwizzle
;
847 out
[n
].src
.SwizzleY
= src
.DimIndSwizzle
;
848 out
[n
].src
.SwizzleZ
= src
.DimIndSwizzle
;
849 out
[n
].src
.SwizzleW
= src
.DimIndSwizzle
;
850 out
[n
].src
.Index
= src
.DimIndIndex
;
852 out
[0].src
.Dimension
= 1;
853 out
[n
].dim
.Indirect
= 0;
854 out
[n
].dim
.Dimension
= 0;
855 out
[n
].dim
.Padding
= 0;
856 out
[n
].dim
.Index
= src
.DimensionIndex
;
866 ureg_emit_dst( struct ureg_program
*ureg
,
867 struct ureg_dst dst
)
870 (dst
.Indirect
? 1 : 0));
872 union tgsi_any_token
*out
= get_tokens( ureg
, DOMAIN_INSN
, size
);
875 assert(dst
.File
!= TGSI_FILE_NULL
);
876 assert(dst
.File
!= TGSI_FILE_CONSTANT
);
877 assert(dst
.File
!= TGSI_FILE_INPUT
);
878 assert(dst
.File
!= TGSI_FILE_SAMPLER
);
879 assert(dst
.File
!= TGSI_FILE_SAMPLER_VIEW
);
880 assert(dst
.File
!= TGSI_FILE_IMMEDIATE
);
881 assert(dst
.File
< TGSI_FILE_COUNT
);
884 out
[n
].dst
.File
= dst
.File
;
885 out
[n
].dst
.WriteMask
= dst
.WriteMask
;
886 out
[n
].dst
.Indirect
= dst
.Indirect
;
887 out
[n
].dst
.Index
= dst
.Index
;
892 out
[n
].src
.File
= TGSI_FILE_ADDRESS
;
893 out
[n
].src
.SwizzleX
= dst
.IndirectSwizzle
;
894 out
[n
].src
.SwizzleY
= dst
.IndirectSwizzle
;
895 out
[n
].src
.SwizzleZ
= dst
.IndirectSwizzle
;
896 out
[n
].src
.SwizzleW
= dst
.IndirectSwizzle
;
897 out
[n
].src
.Index
= dst
.IndirectIndex
;
905 static void validate( unsigned opcode
,
910 const struct tgsi_opcode_info
*info
= tgsi_get_opcode_info( opcode
);
913 assert(nr_dst
== info
->num_dst
);
914 assert(nr_src
== info
->num_src
);
919 struct ureg_emit_insn_result
920 ureg_emit_insn(struct ureg_program
*ureg
,
925 unsigned pred_swizzle_x
,
926 unsigned pred_swizzle_y
,
927 unsigned pred_swizzle_z
,
928 unsigned pred_swizzle_w
,
932 union tgsi_any_token
*out
;
933 uint count
= predicate
? 2 : 1;
934 struct ureg_emit_insn_result result
;
936 validate( opcode
, num_dst
, num_src
);
938 out
= get_tokens( ureg
, DOMAIN_INSN
, count
);
939 out
[0].insn
= tgsi_default_instruction();
940 out
[0].insn
.Opcode
= opcode
;
941 out
[0].insn
.Saturate
= saturate
;
942 out
[0].insn
.NumDstRegs
= num_dst
;
943 out
[0].insn
.NumSrcRegs
= num_src
;
945 result
.insn_token
= ureg
->domain
[DOMAIN_INSN
].count
- count
;
946 result
.extended_token
= result
.insn_token
;
949 out
[0].insn
.Predicate
= 1;
950 out
[1].insn_predicate
= tgsi_default_instruction_predicate();
951 out
[1].insn_predicate
.Negate
= pred_negate
;
952 out
[1].insn_predicate
.SwizzleX
= pred_swizzle_x
;
953 out
[1].insn_predicate
.SwizzleY
= pred_swizzle_y
;
954 out
[1].insn_predicate
.SwizzleZ
= pred_swizzle_z
;
955 out
[1].insn_predicate
.SwizzleW
= pred_swizzle_w
;
958 ureg
->nr_instructions
++;
965 ureg_emit_label(struct ureg_program
*ureg
,
966 unsigned extended_token
,
967 unsigned *label_token
)
969 union tgsi_any_token
*out
, *insn
;
974 out
= get_tokens( ureg
, DOMAIN_INSN
, 1 );
977 insn
= retrieve_token( ureg
, DOMAIN_INSN
, extended_token
);
978 insn
->insn
.Label
= 1;
980 *label_token
= ureg
->domain
[DOMAIN_INSN
].count
- 1;
983 /* Will return a number which can be used in a label to point to the
984 * next instruction to be emitted.
987 ureg_get_instruction_number( struct ureg_program
*ureg
)
989 return ureg
->nr_instructions
;
992 /* Patch a given label (expressed as a token number) to point to a
993 * given instruction (expressed as an instruction number).
996 ureg_fixup_label(struct ureg_program
*ureg
,
997 unsigned label_token
,
998 unsigned instruction_number
)
1000 union tgsi_any_token
*out
= retrieve_token( ureg
, DOMAIN_INSN
, label_token
);
1002 out
->insn_label
.Label
= instruction_number
;
1007 ureg_emit_texture(struct ureg_program
*ureg
,
1008 unsigned extended_token
,
1009 unsigned target
, unsigned num_offsets
)
1011 union tgsi_any_token
*out
, *insn
;
1013 out
= get_tokens( ureg
, DOMAIN_INSN
, 1 );
1014 insn
= retrieve_token( ureg
, DOMAIN_INSN
, extended_token
);
1016 insn
->insn
.Texture
= 1;
1019 out
[0].insn_texture
.Texture
= target
;
1020 out
[0].insn_texture
.NumOffsets
= num_offsets
;
1024 ureg_emit_texture_offset(struct ureg_program
*ureg
,
1025 const struct tgsi_texture_offset
*offset
)
1027 union tgsi_any_token
*out
;
1029 out
= get_tokens( ureg
, DOMAIN_INSN
, 1);
1032 out
[0].insn_texture_offset
= *offset
;
1038 ureg_fixup_insn_size(struct ureg_program
*ureg
,
1041 union tgsi_any_token
*out
= retrieve_token( ureg
, DOMAIN_INSN
, insn
);
1043 assert(out
->insn
.Type
== TGSI_TOKEN_TYPE_INSTRUCTION
);
1044 out
->insn
.NrTokens
= ureg
->domain
[DOMAIN_INSN
].count
- insn
- 1;
1049 ureg_insn(struct ureg_program
*ureg
,
1051 const struct ureg_dst
*dst
,
1053 const struct ureg_src
*src
,
1056 struct ureg_emit_insn_result insn
;
1060 boolean negate
= FALSE
;
1061 unsigned swizzle
[4] = { 0 };
1063 saturate
= nr_dst
? dst
[0].Saturate
: FALSE
;
1064 predicate
= nr_dst
? dst
[0].Predicate
: FALSE
;
1066 negate
= dst
[0].PredNegate
;
1067 swizzle
[0] = dst
[0].PredSwizzleX
;
1068 swizzle
[1] = dst
[0].PredSwizzleY
;
1069 swizzle
[2] = dst
[0].PredSwizzleZ
;
1070 swizzle
[3] = dst
[0].PredSwizzleW
;
1073 insn
= ureg_emit_insn(ureg
,
1085 for (i
= 0; i
< nr_dst
; i
++)
1086 ureg_emit_dst( ureg
, dst
[i
] );
1088 for (i
= 0; i
< nr_src
; i
++)
1089 ureg_emit_src( ureg
, src
[i
] );
1091 ureg_fixup_insn_size( ureg
, insn
.insn_token
);
1095 ureg_tex_insn(struct ureg_program
*ureg
,
1097 const struct ureg_dst
*dst
,
1100 const struct tgsi_texture_offset
*texoffsets
,
1102 const struct ureg_src
*src
,
1105 struct ureg_emit_insn_result insn
;
1109 boolean negate
= FALSE
;
1110 unsigned swizzle
[4] = { 0 };
1112 saturate
= nr_dst
? dst
[0].Saturate
: FALSE
;
1113 predicate
= nr_dst
? dst
[0].Predicate
: FALSE
;
1115 negate
= dst
[0].PredNegate
;
1116 swizzle
[0] = dst
[0].PredSwizzleX
;
1117 swizzle
[1] = dst
[0].PredSwizzleY
;
1118 swizzle
[2] = dst
[0].PredSwizzleZ
;
1119 swizzle
[3] = dst
[0].PredSwizzleW
;
1122 insn
= ureg_emit_insn(ureg
,
1134 ureg_emit_texture( ureg
, insn
.extended_token
, target
, nr_offset
);
1136 for (i
= 0; i
< nr_offset
; i
++)
1137 ureg_emit_texture_offset( ureg
, &texoffsets
[i
]);
1139 for (i
= 0; i
< nr_dst
; i
++)
1140 ureg_emit_dst( ureg
, dst
[i
] );
1142 for (i
= 0; i
< nr_src
; i
++)
1143 ureg_emit_src( ureg
, src
[i
] );
1145 ureg_fixup_insn_size( ureg
, insn
.insn_token
);
1150 ureg_label_insn(struct ureg_program
*ureg
,
1152 const struct ureg_src
*src
,
1154 unsigned *label_token
)
1156 struct ureg_emit_insn_result insn
;
1159 insn
= ureg_emit_insn(ureg
,
1171 ureg_emit_label( ureg
, insn
.extended_token
, label_token
);
1173 for (i
= 0; i
< nr_src
; i
++)
1174 ureg_emit_src( ureg
, src
[i
] );
1176 ureg_fixup_insn_size( ureg
, insn
.insn_token
);
1181 emit_decl_semantic(struct ureg_program
*ureg
,
1184 unsigned semantic_name
,
1185 unsigned semantic_index
,
1186 unsigned usage_mask
)
1188 union tgsi_any_token
*out
= get_tokens(ureg
, DOMAIN_DECL
, 3);
1191 out
[0].decl
.Type
= TGSI_TOKEN_TYPE_DECLARATION
;
1192 out
[0].decl
.NrTokens
= 3;
1193 out
[0].decl
.File
= file
;
1194 out
[0].decl
.UsageMask
= usage_mask
;
1195 out
[0].decl
.Semantic
= 1;
1198 out
[1].decl_range
.First
= index
;
1199 out
[1].decl_range
.Last
= index
;
1202 out
[2].decl_semantic
.Name
= semantic_name
;
1203 out
[2].decl_semantic
.Index
= semantic_index
;
1208 emit_decl_fs(struct ureg_program
*ureg
,
1211 unsigned semantic_name
,
1212 unsigned semantic_index
,
1213 unsigned interpolate
,
1214 unsigned cylindrical_wrap
,
1217 union tgsi_any_token
*out
= get_tokens(ureg
, DOMAIN_DECL
, 4);
1220 out
[0].decl
.Type
= TGSI_TOKEN_TYPE_DECLARATION
;
1221 out
[0].decl
.NrTokens
= 4;
1222 out
[0].decl
.File
= file
;
1223 out
[0].decl
.UsageMask
= TGSI_WRITEMASK_XYZW
; /* FIXME! */
1224 out
[0].decl
.Interpolate
= 1;
1225 out
[0].decl
.Semantic
= 1;
1228 out
[1].decl_range
.First
= index
;
1229 out
[1].decl_range
.Last
= index
;
1232 out
[2].decl_interp
.Interpolate
= interpolate
;
1233 out
[2].decl_interp
.CylindricalWrap
= cylindrical_wrap
;
1234 out
[2].decl_interp
.Centroid
= centroid
;
1237 out
[3].decl_semantic
.Name
= semantic_name
;
1238 out
[3].decl_semantic
.Index
= semantic_index
;
1242 static void emit_decl_range( struct ureg_program
*ureg
,
1247 union tgsi_any_token
*out
= get_tokens( ureg
, DOMAIN_DECL
, 2 );
1250 out
[0].decl
.Type
= TGSI_TOKEN_TYPE_DECLARATION
;
1251 out
[0].decl
.NrTokens
= 2;
1252 out
[0].decl
.File
= file
;
1253 out
[0].decl
.UsageMask
= TGSI_WRITEMASK_XYZW
;
1254 out
[0].decl
.Semantic
= 0;
1257 out
[1].decl_range
.First
= first
;
1258 out
[1].decl_range
.Last
= first
+ count
- 1;
1262 emit_decl_range2D(struct ureg_program
*ureg
,
1268 union tgsi_any_token
*out
= get_tokens(ureg
, DOMAIN_DECL
, 3);
1271 out
[0].decl
.Type
= TGSI_TOKEN_TYPE_DECLARATION
;
1272 out
[0].decl
.NrTokens
= 3;
1273 out
[0].decl
.File
= file
;
1274 out
[0].decl
.UsageMask
= TGSI_WRITEMASK_XYZW
;
1275 out
[0].decl
.Dimension
= 1;
1278 out
[1].decl_range
.First
= first
;
1279 out
[1].decl_range
.Last
= last
;
1282 out
[2].decl_dim
.Index2D
= index2D
;
1286 emit_decl_sampler_view(struct ureg_program
*ureg
,
1289 unsigned return_type_x
,
1290 unsigned return_type_y
,
1291 unsigned return_type_z
,
1292 unsigned return_type_w
)
1294 union tgsi_any_token
*out
= get_tokens(ureg
, DOMAIN_DECL
, 3);
1297 out
[0].decl
.Type
= TGSI_TOKEN_TYPE_DECLARATION
;
1298 out
[0].decl
.NrTokens
= 3;
1299 out
[0].decl
.File
= TGSI_FILE_SAMPLER_VIEW
;
1300 out
[0].decl
.UsageMask
= 0xf;
1303 out
[1].decl_range
.First
= index
;
1304 out
[1].decl_range
.Last
= index
;
1307 out
[2].decl_sampler_view
.Resource
= target
;
1308 out
[2].decl_sampler_view
.ReturnTypeX
= return_type_x
;
1309 out
[2].decl_sampler_view
.ReturnTypeY
= return_type_y
;
1310 out
[2].decl_sampler_view
.ReturnTypeZ
= return_type_z
;
1311 out
[2].decl_sampler_view
.ReturnTypeW
= return_type_w
;
1315 emit_immediate( struct ureg_program
*ureg
,
1319 union tgsi_any_token
*out
= get_tokens( ureg
, DOMAIN_DECL
, 5 );
1322 out
[0].imm
.Type
= TGSI_TOKEN_TYPE_IMMEDIATE
;
1323 out
[0].imm
.NrTokens
= 5;
1324 out
[0].imm
.DataType
= type
;
1325 out
[0].imm
.Padding
= 0;
1327 out
[1].imm_data
.Uint
= v
[0];
1328 out
[2].imm_data
.Uint
= v
[1];
1329 out
[3].imm_data
.Uint
= v
[2];
1330 out
[4].imm_data
.Uint
= v
[3];
1334 emit_property(struct ureg_program
*ureg
,
1338 union tgsi_any_token
*out
= get_tokens(ureg
, DOMAIN_DECL
, 2);
1341 out
[0].prop
.Type
= TGSI_TOKEN_TYPE_PROPERTY
;
1342 out
[0].prop
.NrTokens
= 2;
1343 out
[0].prop
.PropertyName
= name
;
1345 out
[1].prop_data
.Data
= data
;
1349 static void emit_decls( struct ureg_program
*ureg
)
1353 if (ureg
->property_gs_input_prim
!= ~0) {
1354 assert(ureg
->processor
== TGSI_PROCESSOR_GEOMETRY
);
1357 TGSI_PROPERTY_GS_INPUT_PRIM
,
1358 ureg
->property_gs_input_prim
);
1361 if (ureg
->property_gs_output_prim
!= ~0) {
1362 assert(ureg
->processor
== TGSI_PROCESSOR_GEOMETRY
);
1365 TGSI_PROPERTY_GS_OUTPUT_PRIM
,
1366 ureg
->property_gs_output_prim
);
1369 if (ureg
->property_gs_max_vertices
!= ~0) {
1370 assert(ureg
->processor
== TGSI_PROCESSOR_GEOMETRY
);
1373 TGSI_PROPERTY_GS_MAX_OUTPUT_VERTICES
,
1374 ureg
->property_gs_max_vertices
);
1377 if (ureg
->property_fs_coord_origin
) {
1378 assert(ureg
->processor
== TGSI_PROCESSOR_FRAGMENT
);
1381 TGSI_PROPERTY_FS_COORD_ORIGIN
,
1382 ureg
->property_fs_coord_origin
);
1385 if (ureg
->property_fs_coord_pixel_center
) {
1386 assert(ureg
->processor
== TGSI_PROCESSOR_FRAGMENT
);
1389 TGSI_PROPERTY_FS_COORD_PIXEL_CENTER
,
1390 ureg
->property_fs_coord_pixel_center
);
1393 if (ureg
->property_fs_color0_writes_all_cbufs
) {
1394 assert(ureg
->processor
== TGSI_PROCESSOR_FRAGMENT
);
1397 TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
,
1398 ureg
->property_fs_color0_writes_all_cbufs
);
1401 if (ureg
->property_fs_depth_layout
) {
1402 assert(ureg
->processor
== TGSI_PROCESSOR_FRAGMENT
);
1405 TGSI_PROPERTY_FS_DEPTH_LAYOUT
,
1406 ureg
->property_fs_depth_layout
);
1409 if (ureg
->processor
== TGSI_PROCESSOR_VERTEX
) {
1410 for (i
= 0; i
< UREG_MAX_INPUT
; i
++) {
1411 if (ureg
->vs_inputs
[i
/32] & (1 << (i
%32))) {
1412 emit_decl_range( ureg
, TGSI_FILE_INPUT
, i
, 1 );
1415 } else if (ureg
->processor
== TGSI_PROCESSOR_FRAGMENT
) {
1416 for (i
= 0; i
< ureg
->nr_fs_inputs
; i
++) {
1420 ureg
->fs_input
[i
].semantic_name
,
1421 ureg
->fs_input
[i
].semantic_index
,
1422 ureg
->fs_input
[i
].interp
,
1423 ureg
->fs_input
[i
].cylindrical_wrap
,
1424 ureg
->fs_input
[i
].centroid
);
1427 for (i
= 0; i
< ureg
->nr_gs_inputs
; i
++) {
1428 emit_decl_semantic(ureg
,
1430 ureg
->gs_input
[i
].index
,
1431 ureg
->gs_input
[i
].semantic_name
,
1432 ureg
->gs_input
[i
].semantic_index
,
1433 TGSI_WRITEMASK_XYZW
);
1437 for (i
= 0; i
< ureg
->nr_system_values
; i
++) {
1438 emit_decl_semantic(ureg
,
1439 TGSI_FILE_SYSTEM_VALUE
,
1440 ureg
->system_value
[i
].index
,
1441 ureg
->system_value
[i
].semantic_name
,
1442 ureg
->system_value
[i
].semantic_index
,
1443 TGSI_WRITEMASK_XYZW
);
1446 for (i
= 0; i
< ureg
->nr_outputs
; i
++) {
1447 emit_decl_semantic(ureg
,
1450 ureg
->output
[i
].semantic_name
,
1451 ureg
->output
[i
].semantic_index
,
1452 ureg
->output
[i
].usage_mask
);
1455 for (i
= 0; i
< ureg
->nr_samplers
; i
++) {
1456 emit_decl_range( ureg
,
1458 ureg
->sampler
[i
].Index
, 1 );
1461 for (i
= 0; i
< ureg
->nr_sampler_views
; i
++) {
1462 emit_decl_sampler_view(ureg
,
1463 ureg
->sampler_view
[i
].index
,
1464 ureg
->sampler_view
[i
].target
,
1465 ureg
->sampler_view
[i
].return_type_x
,
1466 ureg
->sampler_view
[i
].return_type_y
,
1467 ureg
->sampler_view
[i
].return_type_z
,
1468 ureg
->sampler_view
[i
].return_type_w
);
1471 if (ureg
->const_decls
.nr_constant_ranges
) {
1472 for (i
= 0; i
< ureg
->const_decls
.nr_constant_ranges
; i
++) {
1473 emit_decl_range(ureg
,
1475 ureg
->const_decls
.constant_range
[i
].first
,
1476 ureg
->const_decls
.constant_range
[i
].last
- ureg
->const_decls
.constant_range
[i
].first
+ 1);
1480 for (i
= 0; i
< PIPE_MAX_CONSTANT_BUFFERS
; i
++) {
1481 struct const_decl
*decl
= &ureg
->const_decls2D
[i
];
1483 if (decl
->nr_constant_ranges
) {
1486 for (j
= 0; j
< decl
->nr_constant_ranges
; j
++) {
1487 emit_decl_range2D(ureg
,
1489 decl
->constant_range
[j
].first
,
1490 decl
->constant_range
[j
].last
,
1496 if (ureg
->nr_temps
) {
1497 emit_decl_range( ureg
,
1498 TGSI_FILE_TEMPORARY
,
1499 0, ureg
->nr_temps
);
1502 if (ureg
->nr_addrs
) {
1503 emit_decl_range( ureg
,
1505 0, ureg
->nr_addrs
);
1508 if (ureg
->nr_preds
) {
1509 emit_decl_range(ureg
,
1510 TGSI_FILE_PREDICATE
,
1515 for (i
= 0; i
< ureg
->nr_immediates
; i
++) {
1516 emit_immediate( ureg
,
1517 ureg
->immediate
[i
].value
.u
,
1518 ureg
->immediate
[i
].type
);
1522 /* Append the instruction tokens onto the declarations to build a
1523 * contiguous stream suitable to send to the driver.
1525 static void copy_instructions( struct ureg_program
*ureg
)
1527 unsigned nr_tokens
= ureg
->domain
[DOMAIN_INSN
].count
;
1528 union tgsi_any_token
*out
= get_tokens( ureg
,
1533 ureg
->domain
[DOMAIN_INSN
].tokens
,
1534 nr_tokens
* sizeof out
[0] );
1539 fixup_header_size(struct ureg_program
*ureg
)
1541 union tgsi_any_token
*out
= retrieve_token( ureg
, DOMAIN_DECL
, 0 );
1543 out
->header
.BodySize
= ureg
->domain
[DOMAIN_DECL
].count
- 2;
1548 emit_header( struct ureg_program
*ureg
)
1550 union tgsi_any_token
*out
= get_tokens( ureg
, DOMAIN_DECL
, 2 );
1552 out
[0].header
.HeaderSize
= 2;
1553 out
[0].header
.BodySize
= 0;
1555 out
[1].processor
.Processor
= ureg
->processor
;
1556 out
[1].processor
.Padding
= 0;
1560 const struct tgsi_token
*ureg_finalize( struct ureg_program
*ureg
)
1562 const struct tgsi_token
*tokens
;
1564 emit_header( ureg
);
1566 copy_instructions( ureg
);
1567 fixup_header_size( ureg
);
1569 if (ureg
->domain
[0].tokens
== error_tokens
||
1570 ureg
->domain
[1].tokens
== error_tokens
) {
1571 debug_printf("%s: error in generated shader\n", __FUNCTION__
);
1576 tokens
= &ureg
->domain
[DOMAIN_DECL
].tokens
[0].token
;
1579 debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__
,
1580 ureg
->domain
[DOMAIN_DECL
].count
);
1581 tgsi_dump( tokens
, 0 );
1585 if (tokens
&& !tgsi_sanity_check(tokens
)) {
1586 debug_printf("tgsi_ureg.c, sanity check failed on generated tokens:\n");
1587 tgsi_dump(tokens
, 0);
1597 void *ureg_create_shader( struct ureg_program
*ureg
,
1598 struct pipe_context
*pipe
,
1599 const struct pipe_stream_output_info
*so
)
1601 struct pipe_shader_state state
;
1603 state
.tokens
= ureg_finalize(ureg
);
1608 state
.stream_output
= *so
;
1610 memset(&state
.stream_output
, 0, sizeof(state
.stream_output
));
1612 if (ureg
->processor
== TGSI_PROCESSOR_VERTEX
)
1613 return pipe
->create_vs_state( pipe
, &state
);
1615 return pipe
->create_fs_state( pipe
, &state
);
1619 const struct tgsi_token
*ureg_get_tokens( struct ureg_program
*ureg
,
1620 unsigned *nr_tokens
)
1622 const struct tgsi_token
*tokens
;
1624 ureg_finalize(ureg
);
1626 tokens
= &ureg
->domain
[DOMAIN_DECL
].tokens
[0].token
;
1629 *nr_tokens
= ureg
->domain
[DOMAIN_DECL
].size
;
1631 ureg
->domain
[DOMAIN_DECL
].tokens
= 0;
1632 ureg
->domain
[DOMAIN_DECL
].size
= 0;
1633 ureg
->domain
[DOMAIN_DECL
].order
= 0;
1634 ureg
->domain
[DOMAIN_DECL
].count
= 0;
1640 void ureg_free_tokens( const struct tgsi_token
*tokens
)
1642 FREE((struct tgsi_token
*)tokens
);
1646 struct ureg_program
*ureg_create( unsigned processor
)
1648 struct ureg_program
*ureg
= CALLOC_STRUCT( ureg_program
);
1652 ureg
->processor
= processor
;
1653 ureg
->property_gs_input_prim
= ~0;
1654 ureg
->property_gs_output_prim
= ~0;
1655 ureg
->property_gs_max_vertices
= ~0;
1657 ureg
->free_temps
= util_bitmask_create();
1658 if (ureg
->free_temps
== NULL
)
1669 void ureg_destroy( struct ureg_program
*ureg
)
1673 for (i
= 0; i
< Elements(ureg
->domain
); i
++) {
1674 if (ureg
->domain
[i
].tokens
&&
1675 ureg
->domain
[i
].tokens
!= error_tokens
)
1676 FREE(ureg
->domain
[i
].tokens
);
1679 util_bitmask_destroy(ureg
->free_temps
);