tgsi_ureg.c revision f2fcd5822a0b308e8b9410061996377c0b4a0a91
1/************************************************************************** 2 * 3 * Copyright 2009 VMware, Inc. 4 * All Rights Reserved. 5 * 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: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 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. 25 * 26 **************************************************************************/ 27 28 29#include "pipe/p_context.h" 30#include "pipe/p_state.h" 31#include "tgsi/tgsi_ureg.h" 32#include "tgsi/tgsi_dump.h" 33#include "util/u_memory.h" 34 35union tgsi_any_token { 36 struct tgsi_version version; 37 struct tgsi_header header; 38 struct tgsi_processor processor; 39 struct tgsi_token token; 40 struct tgsi_declaration decl; 41 struct tgsi_declaration_range decl_range; 42 struct tgsi_declaration_semantic decl_semantic; 43 struct tgsi_immediate imm; 44 union tgsi_immediate_data imm_data; 45 struct tgsi_instruction insn; 46 struct tgsi_instruction_ext_nv insn_ext_nv; 47 struct tgsi_instruction_ext_label insn_ext_label; 48 struct tgsi_instruction_ext_texture insn_ext_texture; 49 struct tgsi_instruction_ext_predicate insn_ext_predicate; 50 struct tgsi_src_register src; 51 struct tgsi_src_register_ext_swz src_ext_swz; 52 struct tgsi_src_register_ext_mod src_ext_mod; 53 struct tgsi_dimension dim; 54 struct tgsi_dst_register dst; 55 struct tgsi_dst_register_ext_concode dst_ext_code; 56 struct tgsi_dst_register_ext_modulate dst_ext_mod; 57 struct tgsi_dst_register_ext_predicate dst_ext_pred; 58 unsigned value; 59}; 60 61 62struct ureg_tokens { 63 union tgsi_any_token *tokens; 64 unsigned size; 65 unsigned order; 66 unsigned count; 67}; 68 69#define UREG_MAX_INPUT PIPE_MAX_ATTRIBS 70#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS 71#define UREG_MAX_IMMEDIATE 32 72#define UREG_MAX_TEMP 256 73 74#define DOMAIN_DECL 0 75#define DOMAIN_INSN 1 76 77struct ureg_program 78{ 79 unsigned processor; 80 struct pipe_context *pipe; 81 82 struct { 83 unsigned semantic_name; 84 unsigned semantic_index; 85 unsigned interp; 86 } input[UREG_MAX_INPUT]; 87 unsigned nr_inputs; 88 89 struct { 90 unsigned semantic_name; 91 unsigned semantic_index; 92 } output[UREG_MAX_OUTPUT]; 93 unsigned nr_outputs; 94 95 struct { 96 float v[4]; 97 unsigned nr; 98 } immediate[UREG_MAX_IMMEDIATE]; 99 unsigned nr_immediates; 100 101 unsigned temps_active[UREG_MAX_TEMP / 32]; 102 unsigned nr_temps; 103 104 unsigned nr_constants; 105 unsigned nr_samplers; 106 107 struct ureg_tokens domain[2]; 108}; 109 110static union tgsi_any_token error_tokens[32]; 111 112static void tokens_error( struct ureg_tokens *tokens ) 113{ 114 tokens->tokens = error_tokens; 115 tokens->size = Elements(error_tokens); 116 tokens->count = 0; 117} 118 119 120static void tokens_expand( struct ureg_tokens *tokens, 121 unsigned count ) 122{ 123 unsigned old_size = tokens->size * sizeof(unsigned); 124 125 if (tokens->tokens == error_tokens) 126 goto fail; 127 128 while (tokens->count + count > tokens->size) { 129 tokens->size = (1 << ++tokens->order); 130 } 131 132 tokens->tokens = REALLOC(tokens->tokens, 133 old_size, 134 tokens->size * sizeof(unsigned)); 135 if (tokens->tokens == NULL) 136 goto fail; 137 138 return; 139 140fail: 141 tokens_error(tokens); 142} 143 144static void set_bad( struct ureg_program *ureg ) 145{ 146 tokens_error(&ureg->domain[0]); 147} 148 149 150 151static union tgsi_any_token *get_tokens( struct ureg_program *ureg, 152 unsigned domain, 153 unsigned count ) 154{ 155 struct ureg_tokens *tokens = &ureg->domain[domain]; 156 union tgsi_any_token *result; 157 158 if (tokens->count + count > tokens->size) 159 tokens_expand(tokens, count); 160 161 result = &tokens->tokens[tokens->count]; 162 tokens->count += count; 163 return result; 164} 165 166 167static union tgsi_any_token *retrieve_token( struct ureg_program *ureg, 168 unsigned domain, 169 unsigned nr ) 170{ 171 if (ureg->domain[domain].tokens == error_tokens) 172 return &error_tokens[0]; 173 174 return &ureg->domain[domain].tokens[nr]; 175} 176 177 178 179static INLINE struct ureg_dst 180ureg_dst_register( unsigned file, 181 unsigned index ) 182{ 183 struct ureg_dst dst; 184 185 dst.File = file; 186 dst.WriteMask = TGSI_WRITEMASK_XYZW; 187 dst.Indirect = 0; 188 dst.Saturate = 0; 189 dst.Index = index; 190 dst.Pad1 = 0; 191 dst.Pad2 = 0; 192 193 return dst; 194} 195 196static INLINE struct ureg_src 197ureg_src_register( unsigned file, 198 unsigned index ) 199{ 200 struct ureg_src src; 201 202 src.File = file; 203 src.SwizzleX = TGSI_SWIZZLE_X; 204 src.SwizzleY = TGSI_SWIZZLE_Y; 205 src.SwizzleZ = TGSI_SWIZZLE_Z; 206 src.SwizzleW = TGSI_SWIZZLE_W; 207 src.Pad = 0; 208 src.Indirect = 0; 209 src.Absolute = 0; 210 src.Index = index; 211 src.Negate = 0; 212 213 return src; 214} 215 216 217 218 219static struct ureg_src 220ureg_DECL_input( struct ureg_program *ureg, 221 unsigned name, 222 unsigned index, 223 unsigned interp_mode ) 224{ 225 unsigned i; 226 227 for (i = 0; i < ureg->nr_inputs; i++) { 228 if (ureg->input[i].semantic_name == name && 229 ureg->input[i].semantic_index == index) 230 goto out; 231 } 232 233 if (ureg->nr_inputs < UREG_MAX_INPUT) { 234 ureg->input[i].semantic_name = name; 235 ureg->input[i].semantic_index = index; 236 ureg->input[i].interp = interp_mode; 237 ureg->nr_inputs++; 238 } 239 else { 240 set_bad( ureg ); 241 } 242 243out: 244 return ureg_src_register( TGSI_FILE_INPUT, i ); 245} 246 247 248 249struct ureg_src 250ureg_DECL_fs_input( struct ureg_program *ureg, 251 unsigned name, 252 unsigned index, 253 unsigned interp ) 254{ 255 return ureg_DECL_input( ureg, name, index, interp ); 256} 257 258 259struct ureg_src 260ureg_DECL_vs_input( struct ureg_program *ureg, 261 unsigned name, 262 unsigned index ) 263{ 264 return ureg_DECL_input( ureg, name, index, TGSI_INTERPOLATE_CONSTANT ); 265} 266 267 268struct ureg_dst 269ureg_DECL_output( struct ureg_program *ureg, 270 unsigned name, 271 unsigned index ) 272{ 273 unsigned i; 274 275 for (i = 0; i < ureg->nr_outputs; i++) { 276 if (ureg->output[i].semantic_name == name && 277 ureg->output[i].semantic_index == index) 278 goto out; 279 } 280 281 if (ureg->nr_outputs < UREG_MAX_OUTPUT) { 282 ureg->output[i].semantic_name = name; 283 ureg->output[i].semantic_index = index; 284 ureg->nr_outputs++; 285 } 286 else { 287 set_bad( ureg ); 288 } 289 290out: 291 return ureg_dst_register( TGSI_FILE_OUTPUT, i ); 292} 293 294 295/* Returns a new constant register. Keep track of which have been 296 * referred to so that we can emit decls later. 297 * 298 * There is nothing in this code to bind this constant to any tracked 299 * value or manage any constant_buffer contents -- that's the 300 * resposibility of the calling code. 301 */ 302struct ureg_src ureg_DECL_constant(struct ureg_program *ureg ) 303{ 304 return ureg_src_register( TGSI_FILE_TEMPORARY, ureg->nr_constants++ ); 305} 306 307 308/* Allocate a new temporary. Temporaries greater than UREG_MAX_TEMP 309 * are legal, but will not be released. 310 */ 311struct ureg_dst ureg_DECL_temporary( struct ureg_program *ureg ) 312{ 313 unsigned i; 314 315 for (i = 0; i < UREG_MAX_TEMP; i += 32) { 316 int bit = ffs(~ureg->temps_active[i/32]); 317 if (bit != 0) { 318 i += bit - 1; 319 goto out; 320 } 321 } 322 323 /* No reusable temps, so allocate a new one: 324 */ 325 i = ureg->nr_temps++; 326 327out: 328 if (i < UREG_MAX_TEMP) 329 ureg->temps_active[i/32] |= 1 << (i % 32); 330 331 if (i >= ureg->nr_temps) 332 ureg->nr_temps = i + 1; 333 334 return ureg_dst_register( TGSI_FILE_TEMPORARY, i ); 335} 336 337 338void ureg_release_temporary( struct ureg_program *ureg, 339 struct ureg_dst tmp ) 340{ 341 if (tmp.Index < UREG_MAX_TEMP) 342 ureg->temps_active[tmp.Index/32] &= ~(1 << (tmp.Index % 32)); 343} 344 345 346/* Allocate a new sampler. 347 */ 348struct ureg_src ureg_DECL_sampler( struct ureg_program *ureg ) 349{ 350 return ureg_src_register( TGSI_FILE_SAMPLER, ureg->nr_samplers++ ); 351} 352 353 354 355 356static int match_or_expand_immediate( const float *v, 357 unsigned nr, 358 float *v2, 359 unsigned *nr2, 360 unsigned *swizzle ) 361{ 362 unsigned i, j; 363 364 for (i = 0; i < nr; i++) { 365 boolean found = FALSE; 366 367 for (j = 0; j < *nr2 && !found; j++) { 368 if (v[i] == v2[j]) { 369 *swizzle |= j << (i * 2); 370 found = TRUE; 371 } 372 } 373 374 if (!found) { 375 if (*nr2 >= 4) 376 return FALSE; 377 378 v2[*nr2] = v[i]; 379 *swizzle |= *nr2 << (i * 2); 380 (*nr2)++; 381 } 382 } 383 384 return TRUE; 385} 386 387 388 389 390struct ureg_src ureg_DECL_immediate( struct ureg_program *ureg, 391 const float *v, 392 unsigned nr ) 393{ 394 unsigned i; 395 unsigned swizzle; 396 397 /* Could do a first pass where we examine all existing immediates 398 * without expanding. 399 */ 400 401 for (i = 0; i < ureg->nr_immediates; i++) { 402 if (match_or_expand_immediate( v, 403 nr, 404 ureg->immediate[i].v, 405 &ureg->immediate[i].nr, 406 &swizzle )) 407 goto out; 408 } 409 410 if (ureg->nr_immediates < UREG_MAX_IMMEDIATE) { 411 i = ureg->nr_immediates++; 412 if (match_or_expand_immediate( v, 413 nr, 414 ureg->immediate[i].v, 415 &ureg->immediate[i].nr, 416 &swizzle )) 417 goto out; 418 } 419 420 set_bad( ureg ); 421 422out: 423 return ureg_swizzle( ureg_src_register( TGSI_FILE_IMMEDIATE, i ), 424 (swizzle >> 0) & 0x3, 425 (swizzle >> 2) & 0x3, 426 (swizzle >> 4) & 0x3, 427 (swizzle >> 6) & 0x3); 428} 429 430 431void 432ureg_emit_src( struct ureg_program *ureg, 433 struct ureg_src src ) 434{ 435 unsigned size = (1 + 436 (src.Absolute ? 1 : 0) + 437 (src.Indirect ? 1 : 0)); 438 439 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size ); 440 unsigned n = 0; 441 442 out[n].value = 0; 443 out[n].src.File = src.File; 444 out[n].src.SwizzleX = src.SwizzleX; 445 out[n].src.SwizzleY = src.SwizzleY; 446 out[n].src.SwizzleZ = src.SwizzleZ; 447 out[n].src.SwizzleW = src.SwizzleW; 448 out[n].src.Indirect = src.Indirect; 449 out[n].src.Index = src.Index; 450 n++; 451 452 if (src.Absolute) { 453 out[n].value = 0; 454 out[n].src_ext_mod.Absolute = 1; 455 n++; 456 } 457 458 if (src.Indirect) { 459 out[n].value = 0; 460 out[n].src.File = TGSI_FILE_ADDRESS; 461 out[n].src.SwizzleX = TGSI_SWIZZLE_X; 462 out[n].src.SwizzleY = TGSI_SWIZZLE_X; 463 out[n].src.SwizzleZ = TGSI_SWIZZLE_X; 464 out[n].src.SwizzleW = TGSI_SWIZZLE_X; 465 out[n].src.Indirect = 0; 466 out[n].src.Index = 0; 467 n++; 468 } 469 470 assert(n == size); 471} 472 473 474void 475ureg_emit_dst( struct ureg_program *ureg, 476 struct ureg_dst dst ) 477{ 478 unsigned size = (1 + 479 (dst.Indirect ? 1 : 0)); 480 481 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size ); 482 unsigned n = 0; 483 484 out[n].value = 0; 485 out[n].dst.File = dst.File; 486 out[n].dst.WriteMask = dst.WriteMask; 487 out[n].dst.Indirect = dst.Indirect; 488 out[n].dst.Index = dst.Index; 489 n++; 490 491 if (dst.Indirect) { 492 out[n].value = 0; 493 out[n].src.File = TGSI_FILE_ADDRESS; 494 out[n].src.SwizzleX = TGSI_SWIZZLE_X; 495 out[n].src.SwizzleY = TGSI_SWIZZLE_X; 496 out[n].src.SwizzleZ = TGSI_SWIZZLE_X; 497 out[n].src.SwizzleW = TGSI_SWIZZLE_X; 498 out[n].src.Indirect = 0; 499 out[n].src.Index = 0; 500 n++; 501 } 502 503 assert(n == size); 504} 505 506 507 508unsigned 509ureg_emit_insn(struct ureg_program *ureg, 510 unsigned opcode, 511 boolean saturate, 512 unsigned num_dst, 513 unsigned num_src ) 514{ 515 union tgsi_any_token *out; 516 517 out = get_tokens( ureg, DOMAIN_INSN, 1 ); 518 out[0].value = 0; 519 out[0].insn.Type = TGSI_TOKEN_TYPE_INSTRUCTION; 520 out[0].insn.NrTokens = 0; 521 out[0].insn.Opcode = opcode; 522 out[0].insn.Saturate = saturate; 523 out[0].insn.NrTokens = 0; 524 out[0].insn.NumDstRegs = num_dst; 525 out[0].insn.NumSrcRegs = num_src; 526 out[0].insn.Padding = 0; 527 out[0].insn.Extended = 0; 528 529 return ureg->domain[DOMAIN_INSN].count - 1; 530} 531 532 533void 534ureg_emit_label(struct ureg_program *ureg, 535 unsigned insn_token, 536 unsigned *label_token ) 537{ 538 union tgsi_any_token *out, *insn; 539 540 out = get_tokens( ureg, DOMAIN_INSN, 1 ); 541 insn = retrieve_token( ureg, DOMAIN_INSN, insn_token ); 542 543 insn->insn.Extended = 1; 544 545 out[0].value = 0; 546 out[0].insn_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL; 547} 548 549 550void 551ureg_emit_texture(struct ureg_program *ureg, 552 unsigned insn_token, 553 unsigned target ) 554{ 555 union tgsi_any_token *out, *insn; 556 557 out = get_tokens( ureg, DOMAIN_INSN, 1 ); 558 insn = retrieve_token( ureg, DOMAIN_INSN, insn_token ); 559 560 insn->insn.Extended = 1; 561 562 out[0].value = 0; 563 out[0].insn_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE; 564 out[0].insn_ext_texture.Texture = target; 565} 566 567 568void 569ureg_fixup_insn_size(struct ureg_program *ureg, 570 unsigned insn ) 571{ 572 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_INSN, insn ); 573 574 out->insn.NrTokens = ureg->domain[DOMAIN_INSN].count - insn - 1; 575} 576 577 578 579 580 581static void emit_decl( struct ureg_program *ureg, 582 unsigned file, 583 unsigned index, 584 unsigned semantic_name, 585 unsigned semantic_index, 586 unsigned interp ) 587{ 588 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 ); 589 590 out[0].value = 0; 591 out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; 592 out[0].decl.NrTokens = 3; 593 out[0].decl.File = file; 594 out[0].decl.UsageMask = TGSI_WRITEMASK_XYZW; /* FIXME! */ 595 out[0].decl.Interpolate = interp; 596 out[0].decl.Semantic = 1; 597 598 out[1].value = 0; 599 out[1].decl_range.First = 600 out[1].decl_range.Last = index; 601 602 out[2].value = 0; 603 out[2].decl_semantic.SemanticName = semantic_name; 604 out[2].decl_semantic.SemanticIndex = semantic_index; 605 606} 607 608 609static void emit_decl_range( struct ureg_program *ureg, 610 unsigned file, 611 unsigned first, 612 unsigned count ) 613{ 614 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 2 ); 615 616 out[0].value = 0; 617 out[0].decl.Type = TGSI_TOKEN_TYPE_DECLARATION; 618 out[0].decl.NrTokens = 2; 619 out[0].decl.File = file; 620 out[0].decl.UsageMask = 0xf; 621 out[0].decl.Interpolate = TGSI_INTERPOLATE_CONSTANT; 622 out[0].decl.Semantic = 0; 623 624 out[1].value = 0; 625 out[1].decl_range.First = first; 626 out[1].decl_range.Last = first + count - 1; 627} 628 629static void emit_immediate( struct ureg_program *ureg, 630 const float *v ) 631{ 632 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 5 ); 633 634 out[0].value = 0; 635 out[0].imm.Type = TGSI_TOKEN_TYPE_IMMEDIATE; 636 out[0].imm.NrTokens = 5; 637 out[0].imm.DataType = TGSI_IMM_FLOAT32; 638 out[0].imm.Padding = 0; 639 out[0].imm.Extended = 0; 640 641 out[1].imm_data.Float = v[0]; 642 out[2].imm_data.Float = v[1]; 643 out[3].imm_data.Float = v[2]; 644 out[4].imm_data.Float = v[3]; 645} 646 647 648 649 650static void emit_decls( struct ureg_program *ureg ) 651{ 652 unsigned i; 653 654 for (i = 0; i < ureg->nr_inputs; i++) { 655 emit_decl( ureg, 656 TGSI_FILE_INPUT, 657 i, 658 ureg->input[i].semantic_name, 659 ureg->input[i].semantic_index, 660 ureg->input[i].interp ); 661 } 662 663 for (i = 0; i < ureg->nr_outputs; i++) { 664 emit_decl( ureg, 665 TGSI_FILE_OUTPUT, 666 i, 667 ureg->output[i].semantic_name, 668 ureg->output[i].semantic_index, 669 TGSI_INTERPOLATE_CONSTANT ); 670 } 671 672 if (ureg->nr_samplers) { 673 emit_decl_range( ureg, 674 TGSI_FILE_SAMPLER, 675 0, ureg->nr_samplers ); 676 } 677 678 if (ureg->nr_constants) { 679 emit_decl_range( ureg, 680 TGSI_FILE_CONSTANT, 681 0, ureg->nr_constants ); 682 } 683 684 if (ureg->nr_temps) { 685 emit_decl_range( ureg, 686 TGSI_FILE_TEMPORARY, 687 0, ureg->nr_temps ); 688 } 689 690 for (i = 0; i < ureg->nr_immediates; i++) { 691 emit_immediate( ureg, 692 ureg->immediate[i].v ); 693 } 694} 695 696/* Append the instruction tokens onto the declarations to build a 697 * contiguous stream suitable to send to the driver. 698 */ 699static void copy_instructions( struct ureg_program *ureg ) 700{ 701 unsigned nr_tokens = ureg->domain[DOMAIN_INSN].count; 702 union tgsi_any_token *out = get_tokens( ureg, 703 DOMAIN_DECL, 704 nr_tokens ); 705 706 memcpy(out, 707 ureg->domain[DOMAIN_INSN].tokens, 708 nr_tokens * sizeof out[0] ); 709} 710 711 712static void 713fixup_header_size(struct ureg_program *ureg, 714 unsigned insn ) 715{ 716 union tgsi_any_token *out = retrieve_token( ureg, DOMAIN_DECL, 1 ); 717 718 out->header.BodySize = ureg->domain[DOMAIN_DECL].count - 3; 719} 720 721 722static void 723emit_header( struct ureg_program *ureg ) 724{ 725 union tgsi_any_token *out = get_tokens( ureg, DOMAIN_DECL, 3 ); 726 727 out[0].version.MajorVersion = 1; 728 out[0].version.MinorVersion = 1; 729 out[0].version.Padding = 0; 730 731 out[1].header.HeaderSize = 2; 732 out[1].header.BodySize = 0; 733 734 out[2].processor.Processor = ureg->processor; 735 out[2].processor.Padding = 0; 736} 737 738 739void *ureg_create_shader( struct ureg_program *ureg ) 740{ 741 struct pipe_shader_state state; 742 unsigned insn; 743 744 emit_header( ureg ); 745 emit_decls( ureg ); 746 copy_instructions( ureg ); 747 fixup_header_size( ureg, insn ); 748 749 if (ureg->domain[0].tokens == error_tokens || 750 ureg->domain[1].tokens == error_tokens) { 751 debug_printf("%s: error in generated shader\n", __FUNCTION__); 752 assert(0); 753 return NULL; 754 } 755 756 state.tokens = (const struct tgsi_token *)ureg->domain[DOMAIN_DECL].tokens; 757 758 if (0) { 759 debug_printf("%s: emitted shader %d tokens:\n", __FUNCTION__, 760 ureg->domain[DOMAIN_DECL].count); 761 tgsi_dump( state.tokens, 0 ); 762 } 763 764 if (ureg->processor == TGSI_PROCESSOR_VERTEX) 765 return ureg->pipe->create_vs_state( ureg->pipe, &state ); 766 else 767 return ureg->pipe->create_fs_state( ureg->pipe, &state ); 768} 769 770 771 772 773struct ureg_program *ureg_create( struct pipe_context *pipe, 774 unsigned processor ) 775{ 776 struct ureg_program *ureg = CALLOC_STRUCT( ureg_program ); 777 if (ureg == NULL) 778 return NULL; 779 780 ureg->pipe = pipe; 781 ureg->processor = processor; 782 return ureg; 783} 784 785 786void ureg_destroy( struct ureg_program *ureg ) 787{ 788 unsigned i; 789 790 for (i = 0; i < Elements(ureg->domain); i++) { 791 if (ureg->domain[i].tokens && 792 ureg->domain[i].tokens != error_tokens) 793 FREE(ureg->domain[i].tokens); 794 } 795 796 FREE(ureg); 797} 798