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
;
361 ntex
->texture_index
= tex
->texture_index
;
363 ntex
->texture
= clone_deref_var(state
, tex
->texture
, &ntex
->instr
);
364 ntex
->texture_array_size
= tex
->texture_array_size
;
366 ntex
->sampler_index
= tex
->sampler_index
;
368 ntex
->sampler
= clone_deref_var(state
, tex
->sampler
, &ntex
->instr
);
373 static nir_phi_instr
*
374 clone_phi(clone_state
*state
, const nir_phi_instr
*phi
, nir_block
*nblk
)
376 nir_phi_instr
*nphi
= nir_phi_instr_create(state
->ns
);
378 __clone_dst(state
, &nphi
->instr
, &nphi
->dest
, &phi
->dest
);
380 /* Cloning a phi node is a bit different from other instructions. The
381 * sources of phi instructions are the only time where we can use an SSA
382 * def before it is defined. In order to handle this, we just copy over
383 * the sources from the old phi instruction directly and then fix them up
384 * in a second pass once all the instrutions in the function have been
387 * In order to ensure that the copied sources (which are the same as the
388 * old phi instruction's sources for now) don't get inserted into the old
389 * shader's use-def lists, we have to add the phi instruction *before* we
390 * set up its sources.
392 nir_instr_insert_after_block(nblk
, &nphi
->instr
);
394 foreach_list_typed(nir_phi_src
, src
, node
, &phi
->srcs
) {
395 nir_phi_src
*nsrc
= ralloc(nphi
, nir_phi_src
);
397 /* Just copy the old source for now. */
398 memcpy(nsrc
, src
, sizeof(*src
));
400 /* Since we're not letting nir_insert_instr handle use/def stuff for us,
401 * we have to set the parent_instr manually. It doesn't really matter
402 * when we do it, so we might as well do it here.
404 nsrc
->src
.parent_instr
= &nphi
->instr
;
406 /* Stash it in the list of phi sources. We'll walk this list and fix up
407 * sources at the very end of clone_function_impl.
409 list_add(&nsrc
->src
.use_link
, &state
->phi_srcs
);
411 exec_list_push_tail(&nphi
->srcs
, &nsrc
->node
);
417 static nir_jump_instr
*
418 clone_jump(clone_state
*state
, const nir_jump_instr
*jmp
)
420 nir_jump_instr
*njmp
= nir_jump_instr_create(state
->ns
, jmp
->type
);
425 static nir_call_instr
*
426 clone_call(clone_state
*state
, const nir_call_instr
*call
)
428 nir_function
*ncallee
= lookup_ptr(state
, call
->callee
);
429 nir_call_instr
*ncall
= nir_call_instr_create(state
->ns
, ncallee
);
431 for (unsigned i
= 0; i
< ncall
->num_params
; i
++)
432 ncall
->params
[i
] = clone_deref_var(state
, call
->params
[i
], &ncall
->instr
);
434 ncall
->return_deref
= clone_deref_var(state
, call
->return_deref
,
441 clone_instr(clone_state
*state
, const nir_instr
*instr
)
443 switch (instr
->type
) {
444 case nir_instr_type_alu
:
445 return &clone_alu(state
, nir_instr_as_alu(instr
))->instr
;
446 case nir_instr_type_intrinsic
:
447 return &clone_intrinsic(state
, nir_instr_as_intrinsic(instr
))->instr
;
448 case nir_instr_type_load_const
:
449 return &clone_load_const(state
, nir_instr_as_load_const(instr
))->instr
;
450 case nir_instr_type_ssa_undef
:
451 return &clone_ssa_undef(state
, nir_instr_as_ssa_undef(instr
))->instr
;
452 case nir_instr_type_tex
:
453 return &clone_tex(state
, nir_instr_as_tex(instr
))->instr
;
454 case nir_instr_type_phi
:
455 unreachable("Cannot clone phis with clone_instr");
456 case nir_instr_type_jump
:
457 return &clone_jump(state
, nir_instr_as_jump(instr
))->instr
;
458 case nir_instr_type_call
:
459 return &clone_call(state
, nir_instr_as_call(instr
))->instr
;
460 case nir_instr_type_parallel_copy
:
461 unreachable("Cannot clone parallel copies");
463 unreachable("bad instr type");
469 clone_block(clone_state
*state
, struct exec_list
*cf_list
, const nir_block
*blk
)
471 /* Don't actually create a new block. Just use the one from the tail of
472 * the list. NIR guarantees that the tail of the list is a block and that
473 * no two blocks are side-by-side in the IR; It should be empty.
476 exec_node_data(nir_block
, exec_list_get_tail(cf_list
), cf_node
.node
);
477 assert(nblk
->cf_node
.type
== nir_cf_node_block
);
478 assert(exec_list_is_empty(&nblk
->instr_list
));
480 /* We need this for phi sources */
481 store_ptr(state
, nblk
, blk
);
483 nir_foreach_instr(blk
, instr
) {
484 if (instr
->type
== nir_instr_type_phi
) {
485 /* Phi instructions are a bit of a special case when cloning because
486 * we don't want inserting the instruction to automatically handle
487 * use/defs for us. Instead, we need to wait until all the
488 * blocks/instructions are in so that we can set their sources up.
490 clone_phi(state
, nir_instr_as_phi(instr
), nblk
);
492 nir_instr
*ninstr
= clone_instr(state
, instr
);
493 nir_instr_insert_after_block(nblk
, ninstr
);
501 clone_cf_list(clone_state
*state
, struct exec_list
*dst
,
502 const struct exec_list
*list
);
505 clone_if(clone_state
*state
, struct exec_list
*cf_list
, const nir_if
*i
)
507 nir_if
*ni
= nir_if_create(state
->ns
);
509 __clone_src(state
, ni
, &ni
->condition
, &i
->condition
);
511 nir_cf_node_insert_end(cf_list
, &ni
->cf_node
);
513 clone_cf_list(state
, &ni
->then_list
, &i
->then_list
);
514 clone_cf_list(state
, &ni
->else_list
, &i
->else_list
);
520 clone_loop(clone_state
*state
, struct exec_list
*cf_list
, const nir_loop
*loop
)
522 nir_loop
*nloop
= nir_loop_create(state
->ns
);
524 nir_cf_node_insert_end(cf_list
, &nloop
->cf_node
);
526 clone_cf_list(state
, &nloop
->body
, &loop
->body
);
531 /* clone list of nir_cf_node: */
533 clone_cf_list(clone_state
*state
, struct exec_list
*dst
,
534 const struct exec_list
*list
)
536 foreach_list_typed(nir_cf_node
, cf
, node
, list
) {
538 case nir_cf_node_block
:
539 clone_block(state
, dst
, nir_cf_node_as_block(cf
));
542 clone_if(state
, dst
, nir_cf_node_as_if(cf
));
544 case nir_cf_node_loop
:
545 clone_loop(state
, dst
, nir_cf_node_as_loop(cf
));
548 unreachable("bad cf type");
553 static nir_function_impl
*
554 clone_function_impl(clone_state
*state
, const nir_function_impl
*fi
,
557 nir_function_impl
*nfi
= nir_function_impl_create(nfxn
);
559 clone_var_list(state
, &nfi
->locals
, &fi
->locals
);
560 clone_reg_list(state
, &nfi
->registers
, &fi
->registers
);
561 nfi
->reg_alloc
= fi
->reg_alloc
;
563 nfi
->num_params
= fi
->num_params
;
564 nfi
->params
= ralloc_array(state
->ns
, nir_variable
*, fi
->num_params
);
565 for (unsigned i
= 0; i
< fi
->num_params
; i
++) {
566 nfi
->params
[i
] = lookup_ptr(state
, fi
->params
[i
]);
568 nfi
->return_var
= lookup_ptr(state
, fi
->return_var
);
570 assert(list_empty(&state
->phi_srcs
));
572 clone_cf_list(state
, &nfi
->body
, &fi
->body
);
574 /* After we've cloned almost everything, we have to walk the list of phi
575 * sources and fix them up. Thanks to loops, the block and SSA value for a
576 * phi source may not be defined when we first encounter it. Instead, we
577 * add it to the phi_srcs list and we fix it up here.
579 list_for_each_entry_safe(nir_phi_src
, src
, &state
->phi_srcs
, src
.use_link
) {
580 src
->pred
= lookup_ptr(state
, src
->pred
);
581 assert(src
->src
.is_ssa
);
582 src
->src
.ssa
= lookup_ptr(state
, src
->src
.ssa
);
584 /* Remove from this list and place in the uses of the SSA def */
585 list_del(&src
->src
.use_link
);
586 list_addtail(&src
->src
.use_link
, &src
->src
.ssa
->uses
);
588 assert(list_empty(&state
->phi_srcs
));
590 /* All metadata is invalidated in the cloning process */
591 nfi
->valid_metadata
= 0;
596 static nir_function
*
597 clone_function(clone_state
*state
, const nir_function
*fxn
, nir_shader
*ns
)
599 assert(ns
== state
->ns
);
600 nir_function
*nfxn
= nir_function_create(ns
, fxn
->name
);
602 /* Needed for call instructions */
603 store_ptr(state
, nfxn
, fxn
);
605 nfxn
->num_params
= fxn
->num_params
;
606 nfxn
->params
= ralloc_array(state
->ns
, nir_parameter
, fxn
->num_params
);
607 memcpy(nfxn
->params
, fxn
->params
, sizeof(nir_parameter
) * fxn
->num_params
);
609 nfxn
->return_type
= fxn
->return_type
;
611 /* At first glance, it looks like we should clone the function_impl here.
612 * However, call instructions need to be able to reference at least the
613 * function and those will get processed as we clone the function_impl's.
614 * We stop here and do function_impls as a second pass.
621 nir_shader_clone(void *mem_ctx
, const nir_shader
*s
)
624 init_clone_state(&state
);
626 nir_shader
*ns
= nir_shader_create(mem_ctx
, s
->stage
, s
->options
);
629 clone_var_list(&state
, &ns
->uniforms
, &s
->uniforms
);
630 clone_var_list(&state
, &ns
->inputs
, &s
->inputs
);
631 clone_var_list(&state
, &ns
->outputs
, &s
->outputs
);
632 clone_var_list(&state
, &ns
->globals
, &s
->globals
);
633 clone_var_list(&state
, &ns
->system_values
, &s
->system_values
);
635 /* Go through and clone functions */
636 foreach_list_typed(nir_function
, fxn
, node
, &s
->functions
)
637 clone_function(&state
, fxn
, ns
);
639 /* Only after all functions are cloned can we clone the actual function
640 * implementations. This is because nir_call_instr's need to reference the
641 * functions of other functions and we don't know what order the functions
642 * will have in the list.
644 nir_foreach_function(s
, fxn
) {
645 nir_function
*nfxn
= lookup_ptr(&state
, fxn
);
646 clone_function_impl(&state
, fxn
->impl
, nfxn
);
649 clone_reg_list(&state
, &ns
->registers
, &s
->registers
);
650 ns
->reg_alloc
= s
->reg_alloc
;
653 ns
->info
.name
= ralloc_strdup(ns
, ns
->info
.name
);
655 ns
->info
.label
= ralloc_strdup(ns
, ns
->info
.label
);
657 ns
->num_inputs
= s
->num_inputs
;
658 ns
->num_uniforms
= s
->num_uniforms
;
659 ns
->num_outputs
= s
->num_outputs
;
661 free_clone_state(&state
);