1 /**************************************************************************
3 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
34 #include "tgsi_platform.h"
35 #include "pipe/tgsi/exec/tgsi_core.h"
36 #include "st_mesa_to_tgsi.h"
37 #include "shader/prog_instruction.h"
38 #include "shader/prog_parameter.h"
44 * Map mesa register file to TGSI register file.
48 enum register_file file
)
51 case PROGRAM_UNDEFINED
:
52 return TGSI_FILE_NULL
;
53 case PROGRAM_TEMPORARY
:
54 return TGSI_FILE_TEMPORARY
;
55 //case PROGRAM_LOCAL_PARAM:
56 //case PROGRAM_ENV_PARAM:
57 case PROGRAM_STATE_VAR
:
58 case PROGRAM_NAMED_PARAM
:
60 return TGSI_FILE_CONSTANT
;
61 case PROGRAM_CONSTANT
:
62 return TGSI_FILE_IMMEDIATE
;
64 return TGSI_FILE_INPUT
;
66 return TGSI_FILE_OUTPUT
;
68 return TGSI_FILE_ADDRESS
;
71 return TGSI_FILE_NULL
;
76 * Map mesa register file index to TGSI index.
77 * Take special care when processing input and output indices.
78 * \param file one of TGSI_FILE_x
79 * \param index the mesa register file index
80 * \param inputMapping maps Mesa input indexes to TGSI input indexes
81 * \param outputMapping maps Mesa output indexes to TGSI output indexes
84 map_register_file_index(
87 const GLuint inputMapping
[],
88 const GLuint outputMapping
[],
89 const GLuint immediateMapping
[])
93 /* inputs are mapped according to the user-defined map */
94 return inputMapping
[index
];
96 case TGSI_FILE_OUTPUT
:
97 return outputMapping
[index
];
99 case TGSI_FILE_IMMEDIATE
:
100 return immediateMapping
[index
];
108 * Map mesa texture target to TGSI texture target.
114 switch( textarget
) {
115 case TEXTURE_1D_INDEX
:
116 return TGSI_TEXTURE_1D
;
117 case TEXTURE_2D_INDEX
:
118 return TGSI_TEXTURE_2D
;
119 case TEXTURE_3D_INDEX
:
120 return TGSI_TEXTURE_3D
;
121 case TEXTURE_CUBE_INDEX
:
122 return TGSI_TEXTURE_CUBE
;
123 case TEXTURE_RECT_INDEX
:
124 return TGSI_TEXTURE_RECT
;
129 return TGSI_TEXTURE_1D
;
138 return TGSI_SAT_NONE
;
139 case SATURATE_ZERO_ONE
:
140 return TGSI_SAT_ZERO_ONE
;
141 case SATURATE_PLUS_MINUS_ONE
:
142 return TGSI_SAT_MINUS_PLUS_ONE
;
145 return TGSI_SAT_NONE
;
153 assert( WRITEMASK_X
== TGSI_WRITEMASK_X
);
154 assert( WRITEMASK_Y
== TGSI_WRITEMASK_Y
);
155 assert( WRITEMASK_Z
== TGSI_WRITEMASK_Z
);
156 assert( WRITEMASK_W
== TGSI_WRITEMASK_W
);
157 assert( (writemask
& ~TGSI_WRITEMASK_XYZW
) == 0 );
162 static struct tgsi_full_immediate
163 make_immediate(const float *value
, uint size
)
165 struct tgsi_full_immediate imm
;
166 imm
.Immediate
.Type
= TGSI_TOKEN_TYPE_IMMEDIATE
;
167 imm
.Immediate
.Size
= 1 + size
; /* one for the token itself */
168 imm
.Immediate
.DataType
= TGSI_IMM_FLOAT32
;
169 imm
.u
.ImmediateFloat32
= (struct tgsi_immediate_float32
*) value
;
175 const struct prog_instruction
*inst
,
176 struct tgsi_full_instruction
*fullinst
,
177 const GLuint inputMapping
[],
178 const GLuint outputMapping
[],
179 const GLuint immediateMapping
[],
180 GLuint preamble_size
,
184 struct tgsi_full_dst_register
*fulldst
;
185 struct tgsi_full_src_register
*fullsrc
;
187 *fullinst
= tgsi_default_full_instruction();
189 fullinst
->Instruction
.Saturate
= convert_sat( inst
->SaturateMode
);
190 fullinst
->Instruction
.NumDstRegs
= _mesa_num_inst_dst_regs( inst
->Opcode
);
191 fullinst
->Instruction
.NumSrcRegs
= _mesa_num_inst_src_regs( inst
->Opcode
);
193 fulldst
= &fullinst
->FullDstRegisters
[0];
194 fulldst
->DstRegister
.File
= map_register_file( inst
->DstReg
.File
);
195 fulldst
->DstRegister
.Index
= map_register_file_index(
196 fulldst
->DstRegister
.File
,
202 fulldst
->DstRegister
.WriteMask
= convert_writemask( inst
->DstReg
.WriteMask
);
204 for( i
= 0; i
< fullinst
->Instruction
.NumSrcRegs
; i
++ ) {
207 fullsrc
= &fullinst
->FullSrcRegisters
[i
];
208 fullsrc
->SrcRegister
.File
= map_register_file( inst
->SrcReg
[i
].File
);
209 fullsrc
->SrcRegister
.Index
= map_register_file_index(
210 fullsrc
->SrcRegister
.File
,
211 inst
->SrcReg
[i
].Index
,
216 for( j
= 0; j
< 4; j
++ ) {
219 swz
= GET_SWZ( inst
->SrcReg
[i
].Swizzle
, j
);
220 if( swz
> SWIZZLE_W
) {
221 tgsi_util_set_src_register_extswizzle(
222 &fullsrc
->SrcRegisterExtSwz
,
227 tgsi_util_set_src_register_swizzle(
228 &fullsrc
->SrcRegister
,
234 if( inst
->SrcReg
[i
].NegateBase
== NEGATE_XYZW
) {
235 fullsrc
->SrcRegister
.Negate
= 1;
237 else if( inst
->SrcReg
[i
].NegateBase
!= NEGATE_NONE
) {
238 if( inst
->SrcReg
[i
].NegateBase
& NEGATE_X
) {
239 fullsrc
->SrcRegisterExtSwz
.NegateX
= 1;
241 if( inst
->SrcReg
[i
].NegateBase
& NEGATE_Y
) {
242 fullsrc
->SrcRegisterExtSwz
.NegateY
= 1;
244 if( inst
->SrcReg
[i
].NegateBase
& NEGATE_Z
) {
245 fullsrc
->SrcRegisterExtSwz
.NegateZ
= 1;
247 if( inst
->SrcReg
[i
].NegateBase
& NEGATE_W
) {
248 fullsrc
->SrcRegisterExtSwz
.NegateW
= 1;
252 if( inst
->SrcReg
[i
].Abs
) {
253 fullsrc
->SrcRegisterExtMod
.Absolute
= 1;
256 if( inst
->SrcReg
[i
].NegateAbs
) {
257 fullsrc
->SrcRegisterExtMod
.Negate
= 1;
260 if( inst
->SrcReg
[i
].RelAddr
) {
261 fullsrc
->SrcRegister
.Indirect
= 1;
263 fullsrc
->SrcRegisterInd
.File
= TGSI_FILE_ADDRESS
;
264 fullsrc
->SrcRegisterInd
.Index
= 0;
268 switch( inst
->Opcode
) {
270 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ARL
;
273 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ABS
;
276 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ADD
;
279 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_BGNLOOP2
;
280 fullinst
->InstructionExtLabel
.Label
= inst
->BranchTarget
+ preamble_size
;
283 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_BGNSUB
;
286 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_BRA
;
289 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_BRK
;
292 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_CAL
;
293 fullinst
->InstructionExtLabel
.Label
= inst
->BranchTarget
+ preamble_size
;
296 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_CMP
;
299 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_CONT
;
302 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_COS
;
305 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DDX
;
308 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DDY
;
311 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DP3
;
314 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DP4
;
317 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DPH
;
320 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_DST
;
323 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ELSE
;
324 fullinst
->InstructionExtLabel
.Label
= inst
->BranchTarget
+ preamble_size
;
327 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ENDIF
;
330 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ENDLOOP2
;
331 fullinst
->InstructionExtLabel
.Label
= inst
->BranchTarget
+ preamble_size
;
334 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_ENDSUB
;
337 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_EX2
;
340 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_EXP
;
343 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_FLR
;
346 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_FRC
;
349 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_IF
;
350 fullinst
->InstructionExtLabel
.Label
= inst
->BranchTarget
+ preamble_size
;
353 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_INT
;
356 /* predicated w/ a register */
357 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_KILP
;
361 assert(inst
->DstReg
.CondMask
== COND_TR
);
362 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_KIL
;
365 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_LG2
;
368 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_LOG
;
371 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_LIT
;
374 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_LRP
;
377 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_MAD
;
380 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_MAX
;
383 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_MIN
;
386 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_MOV
;
389 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_MUL
;
392 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_NOISE1
;
395 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_NOISE2
;
398 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_NOISE3
;
401 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_NOISE4
;
404 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_NOP
;
407 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_POW
;
410 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_RCP
;
413 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_RET
;
416 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_RSQ
;
417 tgsi_util_set_full_src_register_sign_mode(
418 &fullinst
->FullSrcRegisters
[0],
419 TGSI_UTIL_SIGN_CLEAR
);
422 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SCS
;
423 fulldst
->DstRegister
.WriteMask
&= TGSI_WRITEMASK_XY
;
426 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SEQ
;
429 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SGE
;
432 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SGT
;
435 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SIN
;
438 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SLE
;
441 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SLT
;
444 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SNE
;
447 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SUB
;
450 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_SWZ
;
453 /* ordinary texture lookup */
454 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_TEX
;
455 fullinst
->Instruction
.NumSrcRegs
= 2;
456 fullinst
->InstructionExtTexture
.Texture
= map_texture_target( inst
->TexSrcTarget
);
457 fullinst
->FullSrcRegisters
[1].SrcRegister
.File
= TGSI_FILE_SAMPLER
;
458 fullinst
->FullSrcRegisters
[1].SrcRegister
.Index
= inst
->TexSrcUnit
;
461 /* texture lookup with LOD bias */
462 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_TXB
;
463 fullinst
->Instruction
.NumSrcRegs
= 2;
464 fullinst
->InstructionExtTexture
.Texture
= map_texture_target( inst
->TexSrcTarget
);
465 fullinst
->FullSrcRegisters
[1].SrcRegister
.File
= TGSI_FILE_SAMPLER
;
466 fullinst
->FullSrcRegisters
[1].SrcRegister
.Index
= inst
->TexSrcUnit
;
469 /* texture lookup with explicit partial derivatives */
470 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_TXD
;
471 fullinst
->Instruction
.NumSrcRegs
= 4;
472 fullinst
->InstructionExtTexture
.Texture
= map_texture_target( inst
->TexSrcTarget
);
473 /* src[0] = coord, src[1] = d[strq]/dx, src[2] = d[strq]/dy */
474 fullinst
->FullSrcRegisters
[3].SrcRegister
.File
= TGSI_FILE_SAMPLER
;
475 fullinst
->FullSrcRegisters
[3].SrcRegister
.Index
= inst
->TexSrcUnit
;
478 /* texture lookup with explicit LOD */
479 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_TXL
;
480 fullinst
->Instruction
.NumSrcRegs
= 2;
481 fullinst
->InstructionExtTexture
.Texture
= map_texture_target( inst
->TexSrcTarget
);
482 fullinst
->FullSrcRegisters
[1].SrcRegister
.File
= TGSI_FILE_SAMPLER
;
483 fullinst
->FullSrcRegisters
[1].SrcRegister
.Index
= inst
->TexSrcUnit
;
486 /* texture lookup with divide by Q component */
487 /* convert to TEX w/ special flag for division */
488 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_TEX
;
489 fullinst
->Instruction
.NumSrcRegs
= 2;
490 fullinst
->InstructionExtTexture
.Texture
= map_texture_target( inst
->TexSrcTarget
);
491 fullinst
->FullSrcRegisters
[0].SrcRegisterExtSwz
.ExtDivide
= TGSI_EXTSWIZZLE_W
;
492 fullinst
->FullSrcRegisters
[1].SrcRegister
.File
= TGSI_FILE_SAMPLER
;
493 fullinst
->FullSrcRegisters
[1].SrcRegister
.Index
= inst
->TexSrcUnit
;
496 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_XPD
;
497 fulldst
->DstRegister
.WriteMask
&= TGSI_WRITEMASK_XYZ
;
500 fullinst
->Instruction
.Opcode
= TGSI_OPCODE_RET
;
508 * \param usage_mask bitfield of TGSI_WRITEMASK_{XYZW} tokens
510 static struct tgsi_full_declaration
513 GLboolean interpolate_info
,
516 GLboolean semantic_info
,
517 GLuint semantic_name
,
518 GLbitfield semantic_index
)
520 struct tgsi_full_declaration decl
;
522 assert(semantic_name
< TGSI_SEMANTIC_COUNT
);
524 decl
= tgsi_default_full_declaration();
525 decl
.Declaration
.File
= TGSI_FILE_INPUT
;
526 decl
.Declaration
.Declare
= TGSI_DECLARE_RANGE
;
527 decl
.Declaration
.UsageMask
= usage_mask
;
528 decl
.Declaration
.Semantic
= semantic_info
;
529 decl
.u
.DeclarationRange
.First
= index
;
530 decl
.u
.DeclarationRange
.Last
= index
;
532 decl
.Semantic
.SemanticName
= semantic_name
;
533 decl
.Semantic
.SemanticIndex
= semantic_index
;
535 if (interpolate_info
) {
536 decl
.Declaration
.Interpolate
= 1;
537 decl
.Interpolation
.Interpolate
= interpolate
;
544 * \param usage_mask bitfield of TGSI_WRITEMASK_{XYZW} tokens
546 static struct tgsi_full_declaration
549 GLuint semantic_name
,
550 GLuint semantic_index
,
551 GLbitfield usage_mask
)
553 struct tgsi_full_declaration decl
;
555 assert(semantic_name
< TGSI_SEMANTIC_COUNT
);
557 decl
= tgsi_default_full_declaration();
558 decl
.Declaration
.File
= TGSI_FILE_OUTPUT
;
559 decl
.Declaration
.Declare
= TGSI_DECLARE_RANGE
;
560 decl
.Declaration
.UsageMask
= usage_mask
;
561 decl
.Declaration
.Semantic
= 1;
562 decl
.u
.DeclarationRange
.First
= index
;
563 decl
.u
.DeclarationRange
.Last
= index
;
564 decl
.Semantic
.SemanticName
= semantic_name
;
565 decl
.Semantic
.SemanticIndex
= semantic_index
;
571 static struct tgsi_full_declaration
576 struct tgsi_full_declaration decl
;
577 decl
= tgsi_default_full_declaration();
578 decl
.Declaration
.File
= TGSI_FILE_TEMPORARY
;
579 decl
.Declaration
.Declare
= TGSI_DECLARE_RANGE
;
580 decl
.u
.DeclarationRange
.First
= start_index
;
581 decl
.u
.DeclarationRange
.Last
= end_index
;
587 * Find the temporaries which are used in the given program.
590 find_temporaries(const struct gl_program
*program
,
591 GLboolean tempsUsed
[MAX_PROGRAM_TEMPS
])
595 for (i
= 0; i
< MAX_PROGRAM_TEMPS
; i
++)
596 tempsUsed
[i
] = GL_FALSE
;
598 for (i
= 0; i
< program
->NumInstructions
; i
++) {
599 const struct prog_instruction
*inst
= program
->Instructions
+ i
;
600 const GLuint n
= _mesa_num_inst_src_regs( inst
->Opcode
);
601 for (j
= 0; j
< n
; j
++) {
602 if (inst
->SrcReg
[j
].File
== PROGRAM_TEMPORARY
)
603 tempsUsed
[inst
->SrcReg
[j
].Index
] = GL_TRUE
;
604 if (inst
->DstReg
.File
== PROGRAM_TEMPORARY
)
605 tempsUsed
[inst
->DstReg
.Index
] = GL_TRUE
;
614 * Translate Mesa program to TGSI format.
615 * \param program the program to translate
616 * \param numInputs number of input registers used
617 * \param inputMapping maps Mesa fragment program inputs to TGSI generic
619 * \param inputSemanticName the TGSI_SEMANTIC flag for each input
620 * \param inputSemanticIndex the semantic index (ex: which texcoord) for each input
621 * \param interpMode the TGSI_INTERPOLATE_LINEAR/PERSP mode for each input
623 * \param numOutputs number of output registers used
624 * \param outputMapping maps Mesa fragment program outputs to TGSI
626 * \param outputSemanticName the TGSI_SEMANTIC flag for each output
627 * \param outputSemanticIndex the semantic index (ex: which texcoord) for each output
628 * \param tokens array to store translated tokens in
629 * \param maxTokens size of the tokens array
633 tgsi_translate_mesa_program(
635 const struct gl_program
*program
,
637 const GLuint inputMapping
[],
638 const ubyte inputSemanticName
[],
639 const ubyte inputSemanticIndex
[],
640 const GLuint interpMode
[],
642 const GLuint outputMapping
[],
643 const ubyte outputSemanticName
[],
644 const ubyte outputSemanticIndex
[],
645 struct tgsi_token
*tokens
,
649 GLuint ti
; /* token index */
650 struct tgsi_header
*header
;
651 struct tgsi_processor
*processor
;
652 struct tgsi_full_instruction fullinst
;
653 GLuint preamble_size
= 0;
654 GLuint immediates
[1000];
655 GLuint numImmediates
= 0;
657 assert(procType
== TGSI_PROCESSOR_FRAGMENT
||
658 procType
== TGSI_PROCESSOR_VERTEX
);
660 *(struct tgsi_version
*) &tokens
[0] = tgsi_build_version();
662 header
= (struct tgsi_header
*) &tokens
[1];
663 *header
= tgsi_build_header();
665 processor
= (struct tgsi_processor
*) &tokens
[2];
666 *processor
= tgsi_build_processor( procType
, header
);
671 * Declare input attributes.
673 if (procType
== TGSI_PROCESSOR_FRAGMENT
) {
674 for (i
= 0; i
< numInputs
; i
++) {
675 struct tgsi_full_declaration fulldecl
;
676 switch (inputSemanticName
[i
]) {
677 case TGSI_SEMANTIC_POSITION
:
678 /* Fragment XY pos */
679 fulldecl
= make_input_decl(i
,
680 GL_TRUE
, TGSI_INTERPOLATE_CONSTANT
,
682 GL_TRUE
, TGSI_SEMANTIC_POSITION
, 0 );
683 ti
+= tgsi_build_full_declaration(
688 /* Fragment ZW pos */
689 fulldecl
= make_input_decl(i
,
690 GL_TRUE
, TGSI_INTERPOLATE_LINEAR
,
692 GL_TRUE
, TGSI_SEMANTIC_POSITION
, 0 );
693 ti
+= tgsi_build_full_declaration(&fulldecl
,
699 fulldecl
= make_input_decl(i
,
700 GL_TRUE
, interpMode
[i
],
702 GL_TRUE
, inputSemanticName
[i
],
703 inputSemanticIndex
[i
]);
704 ti
+= tgsi_build_full_declaration(&fulldecl
,
714 for (i
= 0; i
< numInputs
; i
++) {
715 struct tgsi_full_declaration fulldecl
;
716 fulldecl
= make_input_decl(i
,
720 ti
+= tgsi_build_full_declaration(&fulldecl
,
728 * Declare output attributes.
730 if (procType
== TGSI_PROCESSOR_FRAGMENT
) {
731 for (i
= 0; i
< numOutputs
; i
++) {
732 struct tgsi_full_declaration fulldecl
;
733 switch (outputSemanticName
[i
]) {
734 case TGSI_SEMANTIC_POSITION
:
735 fulldecl
= make_output_decl(i
,
736 TGSI_SEMANTIC_POSITION
, 0, /* Z / Depth */
739 case TGSI_SEMANTIC_COLOR
:
740 fulldecl
= make_output_decl(i
,
741 TGSI_SEMANTIC_COLOR
, 0,
742 TGSI_WRITEMASK_XYZW
);
747 ti
+= tgsi_build_full_declaration(&fulldecl
,
755 for (i
= 0; i
< numOutputs
; i
++) {
756 struct tgsi_full_declaration fulldecl
;
757 fulldecl
= make_output_decl(i
,
758 outputSemanticName
[i
],
759 outputSemanticIndex
[i
],
760 TGSI_WRITEMASK_XYZW
);
761 ti
+= tgsi_build_full_declaration(&fulldecl
,
768 /* temporary decls */
770 GLboolean tempsUsed
[MAX_PROGRAM_TEMPS
+ 1];
771 GLboolean inside_range
= GL_FALSE
;
774 find_temporaries(program
, tempsUsed
);
775 tempsUsed
[MAX_PROGRAM_TEMPS
] = GL_FALSE
;
776 for (i
= 0; i
< MAX_PROGRAM_TEMPS
+ 1; i
++) {
777 if (tempsUsed
[i
] && !inside_range
) {
778 inside_range
= GL_TRUE
;
781 else if (!tempsUsed
[i
] && inside_range
) {
782 struct tgsi_full_declaration fulldecl
;
784 inside_range
= GL_FALSE
;
785 fulldecl
= make_temp_decl( start_range
, i
- 1 );
786 ti
+= tgsi_build_full_declaration(
795 /* immediates/literals */
796 for (i
= 0; program
->Parameters
&& i
< program
->Parameters
->NumParameters
;
798 if (program
->Parameters
->Parameters
[i
].Type
== PROGRAM_CONSTANT
) {
799 struct tgsi_full_immediate fullimm
800 = make_immediate(program
->Parameters
->ParameterValues
[i
],
801 program
->Parameters
->Parameters
[i
].Size
);
802 ti
+= tgsi_build_full_immediate(&fullimm
,
806 immediates
[i
] = numImmediates
;
811 for( i
= 0; i
< program
->NumInstructions
; i
++ ) {
813 &program
->Instructions
[i
],
821 ti
+= tgsi_build_full_instruction(