2 * Copyright © 2015 Red Hat
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include "nir_control_flow_private.h"
27 /* Secret Decoder Ring:
29 * Allocate and clone a foo.
31 * Clone body of foo (ie. parent class, embedded struct, etc)
35 /* maps orig ptr -> cloned ptr: */
36 struct hash_table
*ptr_table
;
38 /* List of phi sources. */
39 struct list_head phi_srcs
;
41 /* new shader object, used as memctx for just about everything else: */
46 init_clone_state(clone_state
*state
)
48 state
->ptr_table
= _mesa_hash_table_create(NULL
, _mesa_hash_pointer
,
49 _mesa_key_pointer_equal
);
50 list_inithead(&state
->phi_srcs
);
54 free_clone_state(clone_state
*state
)
56 _mesa_hash_table_destroy(state
->ptr_table
, NULL
);
60 lookup_ptr(clone_state
*state
, const void *ptr
)
62 struct hash_entry
*entry
;
67 entry
= _mesa_hash_table_search(state
->ptr_table
, ptr
);
68 assert(entry
&& "Failed to find pointer!");
76 store_ptr(clone_state
*state
, void *nptr
, const void *ptr
)
78 _mesa_hash_table_insert(state
->ptr_table
, ptr
, nptr
);
82 clone_constant(clone_state
*state
, const nir_constant
*c
, nir_variable
*nvar
)
84 nir_constant
*nc
= ralloc(nvar
, nir_constant
);
87 nc
->num_elements
= c
->num_elements
;
88 nc
->elements
= ralloc_array(nvar
, nir_constant
*, c
->num_elements
);
89 for (unsigned i
= 0; i
< c
->num_elements
; i
++) {
90 nc
->elements
[i
] = clone_constant(state
, c
->elements
[i
], nvar
);
96 /* NOTE: for cloning nir_variable's, bypass nir_variable_create to avoid
97 * having to deal with locals and globals separately:
100 clone_variable(clone_state
*state
, const nir_variable
*var
)
102 nir_variable
*nvar
= rzalloc(state
->ns
, nir_variable
);
103 store_ptr(state
, nvar
, var
);
105 nvar
->type
= var
->type
;
106 nvar
->name
= ralloc_strdup(nvar
, var
->name
);
107 nvar
->data
= var
->data
;
108 nvar
->num_state_slots
= var
->num_state_slots
;
109 nvar
->state_slots
= ralloc_array(nvar
, nir_state_slot
, var
->num_state_slots
);
110 memcpy(nvar
->state_slots
, var
->state_slots
,
111 var
->num_state_slots
* sizeof(nir_state_slot
));
112 if (var
->constant_initializer
) {
113 nvar
->constant_initializer
=
114 clone_constant(state
, var
->constant_initializer
, nvar
);
116 nvar
->interface_type
= var
->interface_type
;
121 /* clone list of nir_variable: */
123 clone_var_list(clone_state
*state
, struct exec_list
*dst
,
124 const struct exec_list
*list
)
126 exec_list_make_empty(dst
);
127 foreach_list_typed(nir_variable
, var
, node
, list
) {
128 nir_variable
*nvar
= clone_variable(state
, var
);
129 exec_list_push_tail(dst
, &nvar
->node
);
133 /* NOTE: for cloning nir_register's, bypass nir_global/local_reg_create()
134 * to avoid having to deal with locals and globals separately:
136 static nir_register
*
137 clone_register(clone_state
*state
, const nir_register
*reg
)
139 nir_register
*nreg
= rzalloc(state
->ns
, nir_register
);
140 store_ptr(state
, nreg
, reg
);
142 nreg
->num_components
= reg
->num_components
;
143 nreg
->num_array_elems
= reg
->num_array_elems
;
144 nreg
->index
= reg
->index
;
145 nreg
->name
= ralloc_strdup(nreg
, reg
->name
);
146 nreg
->is_global
= reg
->is_global
;
147 nreg
->is_packed
= reg
->is_packed
;
149 /* reconstructing uses/defs/if_uses handled by nir_instr_insert() */
150 list_inithead(&nreg
->uses
);
151 list_inithead(&nreg
->defs
);
152 list_inithead(&nreg
->if_uses
);
157 /* clone list of nir_register: */
159 clone_reg_list(clone_state
*state
, struct exec_list
*dst
,
160 const struct exec_list
*list
)
162 exec_list_make_empty(dst
);
163 foreach_list_typed(nir_register
, reg
, node
, list
) {
164 nir_register
*nreg
= clone_register(state
, reg
);
165 exec_list_push_tail(dst
, &nreg
->node
);
170 __clone_src(clone_state
*state
, void *ninstr_or_if
,
171 nir_src
*nsrc
, const nir_src
*src
)
173 nsrc
->is_ssa
= src
->is_ssa
;
175 nsrc
->ssa
= lookup_ptr(state
, src
->ssa
);
177 nsrc
->reg
.reg
= lookup_ptr(state
, src
->reg
.reg
);
178 if (src
->reg
.indirect
) {
179 nsrc
->reg
.indirect
= ralloc(ninstr_or_if
, nir_src
);
180 __clone_src(state
, ninstr_or_if
, nsrc
->reg
.indirect
, src
->reg
.indirect
);
182 nsrc
->reg
.base_offset
= src
->reg
.base_offset
;
187 __clone_dst(clone_state
*state
, nir_instr
*ninstr
,
188 nir_dest
*ndst
, const nir_dest
*dst
)
190 ndst
->is_ssa
= dst
->is_ssa
;
192 nir_ssa_dest_init(ninstr
, ndst
, dst
->ssa
.num_components
, dst
->ssa
.name
);
193 store_ptr(state
, &ndst
->ssa
, &dst
->ssa
);
195 ndst
->reg
.reg
= lookup_ptr(state
, dst
->reg
.reg
);
196 if (dst
->reg
.indirect
) {
197 ndst
->reg
.indirect
= ralloc(ninstr
, nir_src
);
198 __clone_src(state
, ninstr
, ndst
->reg
.indirect
, dst
->reg
.indirect
);
200 ndst
->reg
.base_offset
= dst
->reg
.base_offset
;
204 static nir_deref
*clone_deref(clone_state
*state
, const nir_deref
*deref
,
205 nir_instr
*ninstr
, nir_deref
*parent
);
207 static nir_deref_var
*
208 clone_deref_var(clone_state
*state
, const nir_deref_var
*dvar
,
211 nir_variable
*nvar
= lookup_ptr(state
, dvar
->var
);
212 nir_deref_var
*ndvar
= nir_deref_var_create(ninstr
, nvar
);
214 if (dvar
->deref
.child
)
215 ndvar
->deref
.child
= clone_deref(state
, dvar
->deref
.child
,
216 ninstr
, &ndvar
->deref
);
221 static nir_deref_array
*
222 clone_deref_array(clone_state
*state
, const nir_deref_array
*darr
,
223 nir_instr
*ninstr
, nir_deref
*parent
)
225 nir_deref_array
*ndarr
= nir_deref_array_create(parent
);
227 ndarr
->deref
.type
= darr
->deref
.type
;
228 if (darr
->deref
.child
)
229 ndarr
->deref
.child
= clone_deref(state
, darr
->deref
.child
,
230 ninstr
, &ndarr
->deref
);
232 ndarr
->deref_array_type
= darr
->deref_array_type
;
233 ndarr
->base_offset
= darr
->base_offset
;
234 if (ndarr
->deref_array_type
== nir_deref_array_type_indirect
)
235 __clone_src(state
, ninstr
, &ndarr
->indirect
, &darr
->indirect
);
240 static nir_deref_struct
*
241 clone_deref_struct(clone_state
*state
, const nir_deref_struct
*dstr
,
242 nir_instr
*ninstr
, nir_deref
*parent
)
244 nir_deref_struct
*ndstr
= nir_deref_struct_create(parent
, dstr
->index
);
246 ndstr
->deref
.type
= dstr
->deref
.type
;
247 if (dstr
->deref
.child
)
248 ndstr
->deref
.child
= clone_deref(state
, dstr
->deref
.child
,
249 ninstr
, &ndstr
->deref
);
255 clone_deref(clone_state
*state
, const nir_deref
*dref
,
256 nir_instr
*ninstr
, nir_deref
*parent
)
258 switch (dref
->deref_type
) {
259 case nir_deref_type_array
:
260 return &clone_deref_array(state
, nir_deref_as_array(dref
),
261 ninstr
, parent
)->deref
;
262 case nir_deref_type_struct
:
263 return &clone_deref_struct(state
, nir_deref_as_struct(dref
),
264 ninstr
, parent
)->deref
;
266 unreachable("bad deref type");
271 static nir_alu_instr
*
272 clone_alu(clone_state
*state
, const nir_alu_instr
*alu
)
274 nir_alu_instr
*nalu
= nir_alu_instr_create(state
->ns
, alu
->op
);
276 __clone_dst(state
, &nalu
->instr
, &nalu
->dest
.dest
, &alu
->dest
.dest
);
277 nalu
->dest
.saturate
= alu
->dest
.saturate
;
278 nalu
->dest
.write_mask
= alu
->dest
.write_mask
;
280 for (unsigned i
= 0; i
< nir_op_infos
[alu
->op
].num_inputs
; i
++) {
281 __clone_src(state
, &nalu
->instr
, &nalu
->src
[i
].src
, &alu
->src
[i
].src
);
282 nalu
->src
[i
].negate
= alu
->src
[i
].negate
;
283 nalu
->src
[i
].abs
= alu
->src
[i
].abs
;
284 memcpy(nalu
->src
[i
].swizzle
, alu
->src
[i
].swizzle
,
285 sizeof(nalu
->src
[i
].swizzle
));
291 static nir_intrinsic_instr
*
292 clone_intrinsic(clone_state
*state
, const nir_intrinsic_instr
*itr
)
294 nir_intrinsic_instr
*nitr
=
295 nir_intrinsic_instr_create(state
->ns
, itr
->intrinsic
);
297 unsigned num_variables
= nir_intrinsic_infos
[itr
->intrinsic
].num_variables
;
298 unsigned num_srcs
= nir_intrinsic_infos
[itr
->intrinsic
].num_srcs
;
300 if (nir_intrinsic_infos
[itr
->intrinsic
].has_dest
)
301 __clone_dst(state
, &nitr
->instr
, &nitr
->dest
, &itr
->dest
);
303 nitr
->num_components
= itr
->num_components
;
304 memcpy(nitr
->const_index
, itr
->const_index
, sizeof(nitr
->const_index
));
306 for (unsigned i
= 0; i
< num_variables
; i
++) {
307 nitr
->variables
[i
] = clone_deref_var(state
, itr
->variables
[i
],
311 for (unsigned i
= 0; i
< num_srcs
; i
++)
312 __clone_src(state
, &nitr
->instr
, &nitr
->src
[i
], &itr
->src
[i
]);
317 static nir_load_const_instr
*
318 clone_load_const(clone_state
*state
, const nir_load_const_instr
*lc
)
320 nir_load_const_instr
*nlc
=
321 nir_load_const_instr_create(state
->ns
, lc
->def
.num_components
);
323 memcpy(&nlc
->value
, &lc
->value
, sizeof(nlc
->value
));
325 store_ptr(state
, &nlc
->def
, &lc
->def
);
330 static nir_ssa_undef_instr
*
331 clone_ssa_undef(clone_state
*state
, const nir_ssa_undef_instr
*sa
)
333 nir_ssa_undef_instr
*nsa
=
334 nir_ssa_undef_instr_create(state
->ns
, sa
->def
.num_components
);
336 store_ptr(state
, &nsa
->def
, &sa
->def
);
341 static nir_tex_instr
*
342 clone_tex(clone_state
*state
, const nir_tex_instr
*tex
)
344 nir_tex_instr
*ntex
= nir_tex_instr_create(state
->ns
, tex
->num_srcs
);
346 ntex
->sampler_dim
= tex
->sampler_dim
;
347 ntex
->dest_type
= tex
->dest_type
;
349 __clone_dst(state
, &ntex
->instr
, &ntex
->dest
, &tex
->dest
);
350 for (unsigned i
= 0; i
< ntex
->num_srcs
; i
++) {
351 ntex
->src
[i
].src_type
= tex
->src
[i
].src_type
;
352 __clone_src(state
, &ntex
->instr
, &ntex
->src
[i
].src
, &tex
->src
[i
].src
);
354 ntex
->coord_components
= tex
->coord_components
;
355 ntex
->is_array
= tex
->is_array
;
356 ntex
->is_shadow
= tex
->is_shadow
;
357 ntex
->is_new_style_shadow
= tex
->is_new_style_shadow
;
358 memcpy(ntex
->const_offset
, tex
->const_offset
, sizeof(ntex
->const_offset
));
359 ntex
->component
= tex
->component
;
360 ntex
->sampler_index
= tex
->sampler_index
;
361 ntex
->sampler_array_size
= tex
->sampler_array_size
;
363 ntex
->sampler
= clone_deref_var(state
, tex
->sampler
, &ntex
->instr
);
368 static nir_phi_instr
*
369 clone_phi(clone_state
*state
, const nir_phi_instr
*phi
, nir_block
*nblk
)
371 nir_phi_instr
*nphi
= nir_phi_instr_create(state
->ns
);
373 __clone_dst(state
, &nphi
->instr
, &nphi
->dest
, &phi
->dest
);
375 /* Cloning a phi node is a bit different from other instructions. The
376 * sources of phi instructions are the only time where we can use an SSA
377 * def before it is defined. In order to handle this, we just copy over
378 * the sources from the old phi instruction directly and then fix them up
379 * in a second pass once all the instrutions in the function have been
382 * In order to ensure that the copied sources (which are the same as the
383 * old phi instruction's sources for now) don't get inserted into the old
384 * shader's use-def lists, we have to add the phi instruction *before* we
385 * set up its sources.
387 nir_instr_insert_after_block(nblk
, &nphi
->instr
);
389 foreach_list_typed(nir_phi_src
, src
, node
, &phi
->srcs
) {
390 nir_phi_src
*nsrc
= ralloc(nphi
, nir_phi_src
);
392 /* Just copy the old source for now. */
393 memcpy(nsrc
, src
, sizeof(*src
));
395 /* Since we're not letting nir_insert_instr handle use/def stuff for us,
396 * we have to set the parent_instr manually. It doesn't really matter
397 * when we do it, so we might as well do it here.
399 nsrc
->src
.parent_instr
= &nphi
->instr
;
401 /* Stash it in the list of phi sources. We'll walk this list and fix up
402 * sources at the very end of clone_function_impl.
404 list_add(&nsrc
->src
.use_link
, &state
->phi_srcs
);
406 exec_list_push_tail(&nphi
->srcs
, &nsrc
->node
);
412 static nir_jump_instr
*
413 clone_jump(clone_state
*state
, const nir_jump_instr
*jmp
)
415 nir_jump_instr
*njmp
= nir_jump_instr_create(state
->ns
, jmp
->type
);
420 static nir_call_instr
*
421 clone_call(clone_state
*state
, const nir_call_instr
*call
)
423 nir_function
*ncallee
= lookup_ptr(state
, call
->callee
);
424 nir_call_instr
*ncall
= nir_call_instr_create(state
->ns
, ncallee
);
426 for (unsigned i
= 0; i
< ncall
->num_params
; i
++)
427 ncall
->params
[i
] = clone_deref_var(state
, call
->params
[i
], &ncall
->instr
);
429 ncall
->return_deref
= clone_deref_var(state
, call
->return_deref
,
436 clone_instr(clone_state
*state
, const nir_instr
*instr
)
438 switch (instr
->type
) {
439 case nir_instr_type_alu
:
440 return &clone_alu(state
, nir_instr_as_alu(instr
))->instr
;
441 case nir_instr_type_intrinsic
:
442 return &clone_intrinsic(state
, nir_instr_as_intrinsic(instr
))->instr
;
443 case nir_instr_type_load_const
:
444 return &clone_load_const(state
, nir_instr_as_load_const(instr
))->instr
;
445 case nir_instr_type_ssa_undef
:
446 return &clone_ssa_undef(state
, nir_instr_as_ssa_undef(instr
))->instr
;
447 case nir_instr_type_tex
:
448 return &clone_tex(state
, nir_instr_as_tex(instr
))->instr
;
449 case nir_instr_type_phi
:
450 unreachable("Cannot clone phis with clone_instr");
451 case nir_instr_type_jump
:
452 return &clone_jump(state
, nir_instr_as_jump(instr
))->instr
;
453 case nir_instr_type_call
:
454 return &clone_call(state
, nir_instr_as_call(instr
))->instr
;
455 case nir_instr_type_parallel_copy
:
456 unreachable("Cannot clone parallel copies");
458 unreachable("bad instr type");
464 clone_block(clone_state
*state
, struct exec_list
*cf_list
, const nir_block
*blk
)
466 /* Don't actually create a new block. Just use the one from the tail of
467 * the list. NIR guarantees that the tail of the list is a block and that
468 * no two blocks are side-by-side in the IR; It should be empty.
471 exec_node_data(nir_block
, exec_list_get_tail(cf_list
), cf_node
.node
);
472 assert(nblk
->cf_node
.type
== nir_cf_node_block
);
473 assert(exec_list_is_empty(&nblk
->instr_list
));
475 /* We need this for phi sources */
476 store_ptr(state
, nblk
, blk
);
478 nir_foreach_instr(blk
, instr
) {
479 if (instr
->type
== nir_instr_type_phi
) {
480 /* Phi instructions are a bit of a special case when cloning because
481 * we don't want inserting the instruction to automatically handle
482 * use/defs for us. Instead, we need to wait until all the
483 * blocks/instructions are in so that we can set their sources up.
485 clone_phi(state
, nir_instr_as_phi(instr
), nblk
);
487 nir_instr
*ninstr
= clone_instr(state
, instr
);
488 nir_instr_insert_after_block(nblk
, ninstr
);
496 clone_cf_list(clone_state
*state
, struct exec_list
*dst
,
497 const struct exec_list
*list
);
500 clone_if(clone_state
*state
, struct exec_list
*cf_list
, const nir_if
*i
)
502 nir_if
*ni
= nir_if_create(state
->ns
);
504 __clone_src(state
, ni
, &ni
->condition
, &i
->condition
);
506 nir_cf_node_insert_end(cf_list
, &ni
->cf_node
);
508 clone_cf_list(state
, &ni
->then_list
, &i
->then_list
);
509 clone_cf_list(state
, &ni
->else_list
, &i
->else_list
);
515 clone_loop(clone_state
*state
, struct exec_list
*cf_list
, const nir_loop
*loop
)
517 nir_loop
*nloop
= nir_loop_create(state
->ns
);
519 nir_cf_node_insert_end(cf_list
, &nloop
->cf_node
);
521 clone_cf_list(state
, &nloop
->body
, &loop
->body
);
526 /* clone list of nir_cf_node: */
528 clone_cf_list(clone_state
*state
, struct exec_list
*dst
,
529 const struct exec_list
*list
)
531 foreach_list_typed(nir_cf_node
, cf
, node
, list
) {
533 case nir_cf_node_block
:
534 clone_block(state
, dst
, nir_cf_node_as_block(cf
));
537 clone_if(state
, dst
, nir_cf_node_as_if(cf
));
539 case nir_cf_node_loop
:
540 clone_loop(state
, dst
, nir_cf_node_as_loop(cf
));
543 unreachable("bad cf type");
548 static nir_function_impl
*
549 clone_function_impl(clone_state
*state
, const nir_function_impl
*fi
,
552 nir_function_impl
*nfi
= nir_function_impl_create(nfxn
);
554 clone_var_list(state
, &nfi
->locals
, &fi
->locals
);
555 clone_reg_list(state
, &nfi
->registers
, &fi
->registers
);
556 nfi
->reg_alloc
= fi
->reg_alloc
;
558 nfi
->num_params
= fi
->num_params
;
559 nfi
->params
= ralloc_array(state
->ns
, nir_variable
*, fi
->num_params
);
560 for (unsigned i
= 0; i
< fi
->num_params
; i
++) {
561 nfi
->params
[i
] = lookup_ptr(state
, fi
->params
[i
]);
563 nfi
->return_var
= lookup_ptr(state
, fi
->return_var
);
565 assert(list_empty(&state
->phi_srcs
));
567 clone_cf_list(state
, &nfi
->body
, &fi
->body
);
569 /* After we've cloned almost everything, we have to walk the list of phi
570 * sources and fix them up. Thanks to loops, the block and SSA value for a
571 * phi source may not be defined when we first encounter it. Instead, we
572 * add it to the phi_srcs list and we fix it up here.
574 list_for_each_entry_safe(nir_phi_src
, src
, &state
->phi_srcs
, src
.use_link
) {
575 src
->pred
= lookup_ptr(state
, src
->pred
);
576 assert(src
->src
.is_ssa
);
577 src
->src
.ssa
= lookup_ptr(state
, src
->src
.ssa
);
579 /* Remove from this list and place in the uses of the SSA def */
580 list_del(&src
->src
.use_link
);
581 list_addtail(&src
->src
.use_link
, &src
->src
.ssa
->uses
);
583 assert(list_empty(&state
->phi_srcs
));
585 /* All metadata is invalidated in the cloning process */
586 nfi
->valid_metadata
= 0;
591 static nir_function
*
592 clone_function(clone_state
*state
, const nir_function
*fxn
, nir_shader
*ns
)
594 assert(ns
== state
->ns
);
595 nir_function
*nfxn
= nir_function_create(ns
, fxn
->name
);
597 /* Needed for call instructions */
598 store_ptr(state
, nfxn
, fxn
);
600 nfxn
->num_params
= fxn
->num_params
;
601 nfxn
->params
= ralloc_array(state
->ns
, nir_parameter
, fxn
->num_params
);
602 memcpy(nfxn
->params
, fxn
->params
, sizeof(nir_parameter
) * fxn
->num_params
);
604 nfxn
->return_type
= fxn
->return_type
;
606 /* At first glance, it looks like we should clone the function_impl here.
607 * However, call instructions need to be able to reference at least the
608 * function and those will get processed as we clone the function_impl's.
609 * We stop here and do function_impls as a second pass.
616 nir_shader_clone(void *mem_ctx
, const nir_shader
*s
)
619 init_clone_state(&state
);
621 nir_shader
*ns
= nir_shader_create(mem_ctx
, s
->stage
, s
->options
);
624 clone_var_list(&state
, &ns
->uniforms
, &s
->uniforms
);
625 clone_var_list(&state
, &ns
->inputs
, &s
->inputs
);
626 clone_var_list(&state
, &ns
->outputs
, &s
->outputs
);
627 clone_var_list(&state
, &ns
->globals
, &s
->globals
);
628 clone_var_list(&state
, &ns
->system_values
, &s
->system_values
);
630 /* Go through and clone functions */
631 foreach_list_typed(nir_function
, fxn
, node
, &s
->functions
)
632 clone_function(&state
, fxn
, ns
);
634 /* Only after all functions are cloned can we clone the actual function
635 * implementations. This is because nir_call_instr's need to reference the
636 * functions of other functions and we don't know what order the functions
637 * will have in the list.
639 nir_foreach_function(s
, fxn
) {
640 nir_function
*nfxn
= lookup_ptr(&state
, fxn
);
641 clone_function_impl(&state
, fxn
->impl
, nfxn
);
644 clone_reg_list(&state
, &ns
->registers
, &s
->registers
);
645 ns
->reg_alloc
= s
->reg_alloc
;
648 ns
->info
.name
= ralloc_strdup(ns
, ns
->info
.name
);
650 ns
->info
.label
= ralloc_strdup(ns
, ns
->info
.label
);
652 ns
->num_inputs
= s
->num_inputs
;
653 ns
->num_uniforms
= s
->num_uniforms
;
654 ns
->num_outputs
= s
->num_outputs
;
656 free_clone_state(&state
);