Clone of mesa.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

tgsi_build.c 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335
  1. /**************************************************************************
  2. *
  3. * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
  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 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.
  25. *
  26. **************************************************************************/
  27. #include "pipe/p_debug.h"
  28. #include "pipe/p_shader_tokens.h"
  29. #include "tgsi_build.h"
  30. #include "tgsi_parse.h"
  31. /*
  32. * version
  33. */
  34. struct tgsi_version
  35. tgsi_build_version( void )
  36. {
  37. struct tgsi_version version;
  38. version.MajorVersion = 1;
  39. version.MinorVersion = 1;
  40. version.Padding = 0;
  41. return version;
  42. }
  43. /*
  44. * header
  45. */
  46. struct tgsi_header
  47. tgsi_build_header( void )
  48. {
  49. struct tgsi_header header;
  50. header.HeaderSize = 1;
  51. header.BodySize = 0;
  52. return header;
  53. }
  54. static void
  55. header_headersize_grow( struct tgsi_header *header )
  56. {
  57. assert( header->HeaderSize < 0xFF );
  58. assert( header->BodySize == 0 );
  59. header->HeaderSize++;
  60. }
  61. static void
  62. header_bodysize_grow( struct tgsi_header *header )
  63. {
  64. assert( header->BodySize < 0xFFFFFF );
  65. header->BodySize++;
  66. }
  67. struct tgsi_processor
  68. tgsi_default_processor( void )
  69. {
  70. struct tgsi_processor processor;
  71. processor.Processor = TGSI_PROCESSOR_FRAGMENT;
  72. processor.Padding = 0;
  73. return processor;
  74. }
  75. struct tgsi_processor
  76. tgsi_build_processor(
  77. unsigned type,
  78. struct tgsi_header *header )
  79. {
  80. struct tgsi_processor processor;
  81. processor = tgsi_default_processor();
  82. processor.Processor = type;
  83. header_headersize_grow( header );
  84. return processor;
  85. }
  86. /*
  87. * declaration
  88. */
  89. struct tgsi_declaration
  90. tgsi_default_declaration( void )
  91. {
  92. struct tgsi_declaration declaration;
  93. declaration.Type = TGSI_TOKEN_TYPE_DECLARATION;
  94. declaration.NrTokens = 1;
  95. declaration.File = TGSI_FILE_NULL;
  96. declaration.UsageMask = TGSI_WRITEMASK_XYZW;
  97. declaration.Interpolate = TGSI_INTERPOLATE_CONSTANT;
  98. declaration.Semantic = 0;
  99. declaration.Centroid = 0;
  100. declaration.Invariant = 0;
  101. declaration.Padding = 0;
  102. declaration.Extended = 0;
  103. return declaration;
  104. }
  105. struct tgsi_declaration
  106. tgsi_build_declaration(
  107. unsigned file,
  108. unsigned usage_mask,
  109. unsigned interpolate,
  110. unsigned semantic,
  111. unsigned centroid,
  112. unsigned invariant,
  113. struct tgsi_header *header )
  114. {
  115. struct tgsi_declaration declaration;
  116. assert( file <= TGSI_FILE_IMMEDIATE );
  117. assert( interpolate <= TGSI_INTERPOLATE_PERSPECTIVE );
  118. declaration = tgsi_default_declaration();
  119. declaration.File = file;
  120. declaration.UsageMask = usage_mask;
  121. declaration.Interpolate = interpolate;
  122. declaration.Semantic = semantic;
  123. declaration.Centroid = centroid;
  124. declaration.Invariant = invariant;
  125. header_bodysize_grow( header );
  126. return declaration;
  127. }
  128. static void
  129. declaration_grow(
  130. struct tgsi_declaration *declaration,
  131. struct tgsi_header *header )
  132. {
  133. assert( declaration->NrTokens < 0xFF );
  134. declaration->NrTokens++;
  135. header_bodysize_grow( header );
  136. }
  137. struct tgsi_full_declaration
  138. tgsi_default_full_declaration( void )
  139. {
  140. struct tgsi_full_declaration full_declaration;
  141. full_declaration.Declaration = tgsi_default_declaration();
  142. full_declaration.DeclarationRange = tgsi_default_declaration_range();
  143. full_declaration.Semantic = tgsi_default_declaration_semantic();
  144. return full_declaration;
  145. }
  146. unsigned
  147. tgsi_build_full_declaration(
  148. const struct tgsi_full_declaration *full_decl,
  149. struct tgsi_token *tokens,
  150. struct tgsi_header *header,
  151. unsigned maxsize )
  152. {
  153. unsigned size = 0;
  154. struct tgsi_declaration *declaration;
  155. struct tgsi_declaration_range *dr;
  156. if( maxsize <= size )
  157. return 0;
  158. declaration = (struct tgsi_declaration *) &tokens[size];
  159. size++;
  160. *declaration = tgsi_build_declaration(
  161. full_decl->Declaration.File,
  162. full_decl->Declaration.UsageMask,
  163. full_decl->Declaration.Interpolate,
  164. full_decl->Declaration.Semantic,
  165. full_decl->Declaration.Centroid,
  166. full_decl->Declaration.Invariant,
  167. header );
  168. if (maxsize <= size)
  169. return 0;
  170. dr = (struct tgsi_declaration_range *) &tokens[size];
  171. size++;
  172. *dr = tgsi_build_declaration_range(
  173. full_decl->DeclarationRange.First,
  174. full_decl->DeclarationRange.Last,
  175. declaration,
  176. header );
  177. if( full_decl->Declaration.Semantic ) {
  178. struct tgsi_declaration_semantic *ds;
  179. if( maxsize <= size )
  180. return 0;
  181. ds = (struct tgsi_declaration_semantic *) &tokens[size];
  182. size++;
  183. *ds = tgsi_build_declaration_semantic(
  184. full_decl->Semantic.SemanticName,
  185. full_decl->Semantic.SemanticIndex,
  186. declaration,
  187. header );
  188. }
  189. return size;
  190. }
  191. struct tgsi_declaration_range
  192. tgsi_default_declaration_range( void )
  193. {
  194. struct tgsi_declaration_range dr;
  195. dr.First = 0;
  196. dr.Last = 0;
  197. return dr;
  198. }
  199. struct tgsi_declaration_range
  200. tgsi_build_declaration_range(
  201. unsigned first,
  202. unsigned last,
  203. struct tgsi_declaration *declaration,
  204. struct tgsi_header *header )
  205. {
  206. struct tgsi_declaration_range declaration_range;
  207. assert( last >= first );
  208. assert( last <= 0xFFFF );
  209. declaration_range = tgsi_default_declaration_range();
  210. declaration_range.First = first;
  211. declaration_range.Last = last;
  212. declaration_grow( declaration, header );
  213. return declaration_range;
  214. }
  215. struct tgsi_declaration_semantic
  216. tgsi_default_declaration_semantic( void )
  217. {
  218. struct tgsi_declaration_semantic ds;
  219. ds.SemanticName = TGSI_SEMANTIC_POSITION;
  220. ds.SemanticIndex = 0;
  221. ds.Padding = 0;
  222. return ds;
  223. }
  224. struct tgsi_declaration_semantic
  225. tgsi_build_declaration_semantic(
  226. unsigned semantic_name,
  227. unsigned semantic_index,
  228. struct tgsi_declaration *declaration,
  229. struct tgsi_header *header )
  230. {
  231. struct tgsi_declaration_semantic ds;
  232. assert( semantic_name <= TGSI_SEMANTIC_COUNT );
  233. assert( semantic_index <= 0xFFFF );
  234. ds = tgsi_default_declaration_semantic();
  235. ds.SemanticName = semantic_name;
  236. ds.SemanticIndex = semantic_index;
  237. declaration_grow( declaration, header );
  238. return ds;
  239. }
  240. /*
  241. * immediate
  242. */
  243. struct tgsi_immediate
  244. tgsi_default_immediate( void )
  245. {
  246. struct tgsi_immediate immediate;
  247. immediate.Type = TGSI_TOKEN_TYPE_IMMEDIATE;
  248. immediate.NrTokens = 1;
  249. immediate.DataType = TGSI_IMM_FLOAT32;
  250. immediate.Padding = 0;
  251. immediate.Extended = 0;
  252. return immediate;
  253. }
  254. struct tgsi_immediate
  255. tgsi_build_immediate(
  256. struct tgsi_header *header )
  257. {
  258. struct tgsi_immediate immediate;
  259. immediate = tgsi_default_immediate();
  260. header_bodysize_grow( header );
  261. return immediate;
  262. }
  263. struct tgsi_full_immediate
  264. tgsi_default_full_immediate( void )
  265. {
  266. struct tgsi_full_immediate fullimm;
  267. fullimm.Immediate = tgsi_default_immediate();
  268. fullimm.u.Pointer = (void *) 0;
  269. return fullimm;
  270. }
  271. static void
  272. immediate_grow(
  273. struct tgsi_immediate *immediate,
  274. struct tgsi_header *header )
  275. {
  276. assert( immediate->NrTokens < 0xFF );
  277. immediate->NrTokens++;
  278. header_bodysize_grow( header );
  279. }
  280. struct tgsi_immediate_float32
  281. tgsi_build_immediate_float32(
  282. float value,
  283. struct tgsi_immediate *immediate,
  284. struct tgsi_header *header )
  285. {
  286. struct tgsi_immediate_float32 immediate_float32;
  287. immediate_float32.Float = value;
  288. immediate_grow( immediate, header );
  289. return immediate_float32;
  290. }
  291. unsigned
  292. tgsi_build_full_immediate(
  293. const struct tgsi_full_immediate *full_imm,
  294. struct tgsi_token *tokens,
  295. struct tgsi_header *header,
  296. unsigned maxsize )
  297. {
  298. unsigned size = 0, i;
  299. struct tgsi_immediate *immediate;
  300. if( maxsize <= size )
  301. return 0;
  302. immediate = (struct tgsi_immediate *) &tokens[size];
  303. size++;
  304. *immediate = tgsi_build_immediate( header );
  305. for( i = 0; i < full_imm->Immediate.NrTokens - 1; i++ ) {
  306. struct tgsi_immediate_float32 *if32;
  307. if( maxsize <= size )
  308. return 0;
  309. if32 = (struct tgsi_immediate_float32 *) &tokens[size];
  310. size++;
  311. *if32 = tgsi_build_immediate_float32(
  312. full_imm->u.ImmediateFloat32[i].Float,
  313. immediate,
  314. header );
  315. }
  316. return size;
  317. }
  318. /*
  319. * instruction
  320. */
  321. struct tgsi_instruction
  322. tgsi_default_instruction( void )
  323. {
  324. struct tgsi_instruction instruction;
  325. instruction.Type = TGSI_TOKEN_TYPE_INSTRUCTION;
  326. instruction.NrTokens = 1;
  327. instruction.Opcode = TGSI_OPCODE_MOV;
  328. instruction.Saturate = TGSI_SAT_NONE;
  329. instruction.NumDstRegs = 1;
  330. instruction.NumSrcRegs = 1;
  331. instruction.Padding = 0;
  332. instruction.Extended = 0;
  333. return instruction;
  334. }
  335. struct tgsi_instruction
  336. tgsi_build_instruction(
  337. unsigned opcode,
  338. unsigned saturate,
  339. unsigned num_dst_regs,
  340. unsigned num_src_regs,
  341. struct tgsi_header *header )
  342. {
  343. struct tgsi_instruction instruction;
  344. assert (opcode <= TGSI_OPCODE_LAST);
  345. assert (saturate <= TGSI_SAT_MINUS_PLUS_ONE);
  346. assert (num_dst_regs <= 3);
  347. assert (num_src_regs <= 15);
  348. instruction = tgsi_default_instruction();
  349. instruction.Opcode = opcode;
  350. instruction.Saturate = saturate;
  351. instruction.NumDstRegs = num_dst_regs;
  352. instruction.NumSrcRegs = num_src_regs;
  353. header_bodysize_grow( header );
  354. return instruction;
  355. }
  356. static void
  357. instruction_grow(
  358. struct tgsi_instruction *instruction,
  359. struct tgsi_header *header )
  360. {
  361. assert (instruction->NrTokens < 0xFF);
  362. instruction->NrTokens++;
  363. header_bodysize_grow( header );
  364. }
  365. struct tgsi_full_instruction
  366. tgsi_default_full_instruction( void )
  367. {
  368. struct tgsi_full_instruction full_instruction;
  369. unsigned i;
  370. full_instruction.Instruction = tgsi_default_instruction();
  371. full_instruction.InstructionExtNv = tgsi_default_instruction_ext_nv();
  372. full_instruction.InstructionExtLabel = tgsi_default_instruction_ext_label();
  373. full_instruction.InstructionExtTexture = tgsi_default_instruction_ext_texture();
  374. for( i = 0; i < TGSI_FULL_MAX_DST_REGISTERS; i++ ) {
  375. full_instruction.FullDstRegisters[i] = tgsi_default_full_dst_register();
  376. }
  377. for( i = 0; i < TGSI_FULL_MAX_SRC_REGISTERS; i++ ) {
  378. full_instruction.FullSrcRegisters[i] = tgsi_default_full_src_register();
  379. }
  380. return full_instruction;
  381. }
  382. unsigned
  383. tgsi_build_full_instruction(
  384. const struct tgsi_full_instruction *full_inst,
  385. struct tgsi_token *tokens,
  386. struct tgsi_header *header,
  387. unsigned maxsize )
  388. {
  389. unsigned size = 0;
  390. unsigned i;
  391. struct tgsi_instruction *instruction;
  392. struct tgsi_token *prev_token;
  393. if( maxsize <= size )
  394. return 0;
  395. instruction = (struct tgsi_instruction *) &tokens[size];
  396. size++;
  397. *instruction = tgsi_build_instruction(
  398. full_inst->Instruction.Opcode,
  399. full_inst->Instruction.Saturate,
  400. full_inst->Instruction.NumDstRegs,
  401. full_inst->Instruction.NumSrcRegs,
  402. header );
  403. prev_token = (struct tgsi_token *) instruction;
  404. if( tgsi_compare_instruction_ext_nv(
  405. full_inst->InstructionExtNv,
  406. tgsi_default_instruction_ext_nv() ) ) {
  407. struct tgsi_instruction_ext_nv *instruction_ext_nv;
  408. if( maxsize <= size )
  409. return 0;
  410. instruction_ext_nv =
  411. (struct tgsi_instruction_ext_nv *) &tokens[size];
  412. size++;
  413. *instruction_ext_nv = tgsi_build_instruction_ext_nv(
  414. full_inst->InstructionExtNv.Precision,
  415. full_inst->InstructionExtNv.CondDstIndex,
  416. full_inst->InstructionExtNv.CondFlowIndex,
  417. full_inst->InstructionExtNv.CondMask,
  418. full_inst->InstructionExtNv.CondSwizzleX,
  419. full_inst->InstructionExtNv.CondSwizzleY,
  420. full_inst->InstructionExtNv.CondSwizzleZ,
  421. full_inst->InstructionExtNv.CondSwizzleW,
  422. full_inst->InstructionExtNv.CondDstUpdate,
  423. full_inst->InstructionExtNv.CondFlowEnable,
  424. prev_token,
  425. instruction,
  426. header );
  427. prev_token = (struct tgsi_token *) instruction_ext_nv;
  428. }
  429. if( tgsi_compare_instruction_ext_label(
  430. full_inst->InstructionExtLabel,
  431. tgsi_default_instruction_ext_label() ) ) {
  432. struct tgsi_instruction_ext_label *instruction_ext_label;
  433. if( maxsize <= size )
  434. return 0;
  435. instruction_ext_label =
  436. (struct tgsi_instruction_ext_label *) &tokens[size];
  437. size++;
  438. *instruction_ext_label = tgsi_build_instruction_ext_label(
  439. full_inst->InstructionExtLabel.Label,
  440. prev_token,
  441. instruction,
  442. header );
  443. prev_token = (struct tgsi_token *) instruction_ext_label;
  444. }
  445. if( tgsi_compare_instruction_ext_texture(
  446. full_inst->InstructionExtTexture,
  447. tgsi_default_instruction_ext_texture() ) ) {
  448. struct tgsi_instruction_ext_texture *instruction_ext_texture;
  449. if( maxsize <= size )
  450. return 0;
  451. instruction_ext_texture =
  452. (struct tgsi_instruction_ext_texture *) &tokens[size];
  453. size++;
  454. *instruction_ext_texture = tgsi_build_instruction_ext_texture(
  455. full_inst->InstructionExtTexture.Texture,
  456. prev_token,
  457. instruction,
  458. header );
  459. prev_token = (struct tgsi_token *) instruction_ext_texture;
  460. }
  461. for( i = 0; i < full_inst->Instruction.NumDstRegs; i++ ) {
  462. const struct tgsi_full_dst_register *reg = &full_inst->FullDstRegisters[i];
  463. struct tgsi_dst_register *dst_register;
  464. struct tgsi_token *prev_token;
  465. if( maxsize <= size )
  466. return 0;
  467. dst_register = (struct tgsi_dst_register *) &tokens[size];
  468. size++;
  469. *dst_register = tgsi_build_dst_register(
  470. reg->DstRegister.File,
  471. reg->DstRegister.WriteMask,
  472. reg->DstRegister.Index,
  473. instruction,
  474. header );
  475. prev_token = (struct tgsi_token *) dst_register;
  476. if( tgsi_compare_dst_register_ext_concode(
  477. reg->DstRegisterExtConcode,
  478. tgsi_default_dst_register_ext_concode() ) ) {
  479. struct tgsi_dst_register_ext_concode *dst_register_ext_concode;
  480. if( maxsize <= size )
  481. return 0;
  482. dst_register_ext_concode =
  483. (struct tgsi_dst_register_ext_concode *) &tokens[size];
  484. size++;
  485. *dst_register_ext_concode = tgsi_build_dst_register_ext_concode(
  486. reg->DstRegisterExtConcode.CondMask,
  487. reg->DstRegisterExtConcode.CondSwizzleX,
  488. reg->DstRegisterExtConcode.CondSwizzleY,
  489. reg->DstRegisterExtConcode.CondSwizzleZ,
  490. reg->DstRegisterExtConcode.CondSwizzleW,
  491. reg->DstRegisterExtConcode.CondSrcIndex,
  492. prev_token,
  493. instruction,
  494. header );
  495. prev_token = (struct tgsi_token *) dst_register_ext_concode;
  496. }
  497. if( tgsi_compare_dst_register_ext_modulate(
  498. reg->DstRegisterExtModulate,
  499. tgsi_default_dst_register_ext_modulate() ) ) {
  500. struct tgsi_dst_register_ext_modulate *dst_register_ext_modulate;
  501. if( maxsize <= size )
  502. return 0;
  503. dst_register_ext_modulate =
  504. (struct tgsi_dst_register_ext_modulate *) &tokens[size];
  505. size++;
  506. *dst_register_ext_modulate = tgsi_build_dst_register_ext_modulate(
  507. reg->DstRegisterExtModulate.Modulate,
  508. prev_token,
  509. instruction,
  510. header );
  511. prev_token = (struct tgsi_token *) dst_register_ext_modulate;
  512. }
  513. }
  514. for( i = 0; i < full_inst->Instruction.NumSrcRegs; i++ ) {
  515. const struct tgsi_full_src_register *reg = &full_inst->FullSrcRegisters[i];
  516. struct tgsi_src_register *src_register;
  517. struct tgsi_token *prev_token;
  518. if( maxsize <= size )
  519. return 0;
  520. src_register = (struct tgsi_src_register *) &tokens[size];
  521. size++;
  522. *src_register = tgsi_build_src_register(
  523. reg->SrcRegister.File,
  524. reg->SrcRegister.SwizzleX,
  525. reg->SrcRegister.SwizzleY,
  526. reg->SrcRegister.SwizzleZ,
  527. reg->SrcRegister.SwizzleW,
  528. reg->SrcRegister.Negate,
  529. reg->SrcRegister.Indirect,
  530. reg->SrcRegister.Dimension,
  531. reg->SrcRegister.Index,
  532. instruction,
  533. header );
  534. prev_token = (struct tgsi_token *) src_register;
  535. if( tgsi_compare_src_register_ext_swz(
  536. reg->SrcRegisterExtSwz,
  537. tgsi_default_src_register_ext_swz() ) ) {
  538. struct tgsi_src_register_ext_swz *src_register_ext_swz;
  539. /* Use of the extended swizzle requires the simple swizzle to be identity.
  540. */
  541. assert( reg->SrcRegister.SwizzleX == TGSI_SWIZZLE_X );
  542. assert( reg->SrcRegister.SwizzleY == TGSI_SWIZZLE_Y );
  543. assert( reg->SrcRegister.SwizzleZ == TGSI_SWIZZLE_Z );
  544. assert( reg->SrcRegister.SwizzleW == TGSI_SWIZZLE_W );
  545. assert( reg->SrcRegister.Negate == FALSE );
  546. if( maxsize <= size )
  547. return 0;
  548. src_register_ext_swz =
  549. (struct tgsi_src_register_ext_swz *) &tokens[size];
  550. size++;
  551. *src_register_ext_swz = tgsi_build_src_register_ext_swz(
  552. reg->SrcRegisterExtSwz.ExtSwizzleX,
  553. reg->SrcRegisterExtSwz.ExtSwizzleY,
  554. reg->SrcRegisterExtSwz.ExtSwizzleZ,
  555. reg->SrcRegisterExtSwz.ExtSwizzleW,
  556. reg->SrcRegisterExtSwz.NegateX,
  557. reg->SrcRegisterExtSwz.NegateY,
  558. reg->SrcRegisterExtSwz.NegateZ,
  559. reg->SrcRegisterExtSwz.NegateW,
  560. prev_token,
  561. instruction,
  562. header );
  563. prev_token = (struct tgsi_token *) src_register_ext_swz;
  564. }
  565. if( tgsi_compare_src_register_ext_mod(
  566. reg->SrcRegisterExtMod,
  567. tgsi_default_src_register_ext_mod() ) ) {
  568. struct tgsi_src_register_ext_mod *src_register_ext_mod;
  569. if( maxsize <= size )
  570. return 0;
  571. src_register_ext_mod =
  572. (struct tgsi_src_register_ext_mod *) &tokens[size];
  573. size++;
  574. *src_register_ext_mod = tgsi_build_src_register_ext_mod(
  575. reg->SrcRegisterExtMod.Complement,
  576. reg->SrcRegisterExtMod.Bias,
  577. reg->SrcRegisterExtMod.Scale2X,
  578. reg->SrcRegisterExtMod.Absolute,
  579. reg->SrcRegisterExtMod.Negate,
  580. prev_token,
  581. instruction,
  582. header );
  583. prev_token = (struct tgsi_token *) src_register_ext_mod;
  584. }
  585. if( reg->SrcRegister.Indirect ) {
  586. struct tgsi_src_register *ind;
  587. if( maxsize <= size )
  588. return 0;
  589. ind = (struct tgsi_src_register *) &tokens[size];
  590. size++;
  591. *ind = tgsi_build_src_register(
  592. reg->SrcRegisterInd.File,
  593. reg->SrcRegisterInd.SwizzleX,
  594. reg->SrcRegisterInd.SwizzleY,
  595. reg->SrcRegisterInd.SwizzleZ,
  596. reg->SrcRegisterInd.SwizzleW,
  597. reg->SrcRegisterInd.Negate,
  598. reg->SrcRegisterInd.Indirect,
  599. reg->SrcRegisterInd.Dimension,
  600. reg->SrcRegisterInd.Index,
  601. instruction,
  602. header );
  603. }
  604. if( reg->SrcRegister.Dimension ) {
  605. struct tgsi_dimension *dim;
  606. assert( !reg->SrcRegisterDim.Dimension );
  607. if( maxsize <= size )
  608. return 0;
  609. dim = (struct tgsi_dimension *) &tokens[size];
  610. size++;
  611. *dim = tgsi_build_dimension(
  612. reg->SrcRegisterDim.Indirect,
  613. reg->SrcRegisterDim.Index,
  614. instruction,
  615. header );
  616. if( reg->SrcRegisterDim.Indirect ) {
  617. struct tgsi_src_register *ind;
  618. if( maxsize <= size )
  619. return 0;
  620. ind = (struct tgsi_src_register *) &tokens[size];
  621. size++;
  622. *ind = tgsi_build_src_register(
  623. reg->SrcRegisterDimInd.File,
  624. reg->SrcRegisterDimInd.SwizzleX,
  625. reg->SrcRegisterDimInd.SwizzleY,
  626. reg->SrcRegisterDimInd.SwizzleZ,
  627. reg->SrcRegisterDimInd.SwizzleW,
  628. reg->SrcRegisterDimInd.Negate,
  629. reg->SrcRegisterDimInd.Indirect,
  630. reg->SrcRegisterDimInd.Dimension,
  631. reg->SrcRegisterDimInd.Index,
  632. instruction,
  633. header );
  634. }
  635. }
  636. }
  637. return size;
  638. }
  639. struct tgsi_instruction_ext_nv
  640. tgsi_default_instruction_ext_nv( void )
  641. {
  642. struct tgsi_instruction_ext_nv instruction_ext_nv;
  643. instruction_ext_nv.Type = TGSI_INSTRUCTION_EXT_TYPE_NV;
  644. instruction_ext_nv.Precision = TGSI_PRECISION_DEFAULT;
  645. instruction_ext_nv.CondDstIndex = 0;
  646. instruction_ext_nv.CondFlowIndex = 0;
  647. instruction_ext_nv.CondMask = TGSI_CC_TR;
  648. instruction_ext_nv.CondSwizzleX = TGSI_SWIZZLE_X;
  649. instruction_ext_nv.CondSwizzleY = TGSI_SWIZZLE_Y;
  650. instruction_ext_nv.CondSwizzleZ = TGSI_SWIZZLE_Z;
  651. instruction_ext_nv.CondSwizzleW = TGSI_SWIZZLE_W;
  652. instruction_ext_nv.CondDstUpdate = 0;
  653. instruction_ext_nv.CondFlowEnable = 0;
  654. instruction_ext_nv.Padding = 0;
  655. instruction_ext_nv.Extended = 0;
  656. return instruction_ext_nv;
  657. }
  658. /** test for inequality of 32-bit values pointed to by a and b */
  659. static INLINE boolean
  660. compare32(const void *a, const void *b)
  661. {
  662. return *((uint32_t *) a) != *((uint32_t *) b);
  663. }
  664. unsigned
  665. tgsi_compare_instruction_ext_nv(
  666. struct tgsi_instruction_ext_nv a,
  667. struct tgsi_instruction_ext_nv b )
  668. {
  669. a.Padding = b.Padding = 0;
  670. a.Extended = b.Extended = 0;
  671. return compare32(&a, &b);
  672. }
  673. struct tgsi_instruction_ext_nv
  674. tgsi_build_instruction_ext_nv(
  675. unsigned precision,
  676. unsigned cond_dst_index,
  677. unsigned cond_flow_index,
  678. unsigned cond_mask,
  679. unsigned cond_swizzle_x,
  680. unsigned cond_swizzle_y,
  681. unsigned cond_swizzle_z,
  682. unsigned cond_swizzle_w,
  683. unsigned cond_dst_update,
  684. unsigned cond_flow_enable,
  685. struct tgsi_token *prev_token,
  686. struct tgsi_instruction *instruction,
  687. struct tgsi_header *header )
  688. {
  689. struct tgsi_instruction_ext_nv instruction_ext_nv;
  690. instruction_ext_nv = tgsi_default_instruction_ext_nv();
  691. instruction_ext_nv.Precision = precision;
  692. instruction_ext_nv.CondDstIndex = cond_dst_index;
  693. instruction_ext_nv.CondFlowIndex = cond_flow_index;
  694. instruction_ext_nv.CondMask = cond_mask;
  695. instruction_ext_nv.CondSwizzleX = cond_swizzle_x;
  696. instruction_ext_nv.CondSwizzleY = cond_swizzle_y;
  697. instruction_ext_nv.CondSwizzleZ = cond_swizzle_z;
  698. instruction_ext_nv.CondSwizzleW = cond_swizzle_w;
  699. instruction_ext_nv.CondDstUpdate = cond_dst_update;
  700. instruction_ext_nv.CondFlowEnable = cond_flow_enable;
  701. prev_token->Extended = 1;
  702. instruction_grow( instruction, header );
  703. return instruction_ext_nv;
  704. }
  705. struct tgsi_instruction_ext_label
  706. tgsi_default_instruction_ext_label( void )
  707. {
  708. struct tgsi_instruction_ext_label instruction_ext_label;
  709. instruction_ext_label.Type = TGSI_INSTRUCTION_EXT_TYPE_LABEL;
  710. instruction_ext_label.Label = 0;
  711. instruction_ext_label.Padding = 0;
  712. instruction_ext_label.Extended = 0;
  713. return instruction_ext_label;
  714. }
  715. unsigned
  716. tgsi_compare_instruction_ext_label(
  717. struct tgsi_instruction_ext_label a,
  718. struct tgsi_instruction_ext_label b )
  719. {
  720. a.Padding = b.Padding = 0;
  721. a.Extended = b.Extended = 0;
  722. return compare32(&a, &b);
  723. }
  724. struct tgsi_instruction_ext_label
  725. tgsi_build_instruction_ext_label(
  726. unsigned label,
  727. struct tgsi_token *prev_token,
  728. struct tgsi_instruction *instruction,
  729. struct tgsi_header *header )
  730. {
  731. struct tgsi_instruction_ext_label instruction_ext_label;
  732. instruction_ext_label = tgsi_default_instruction_ext_label();
  733. instruction_ext_label.Label = label;
  734. prev_token->Extended = 1;
  735. instruction_grow( instruction, header );
  736. return instruction_ext_label;
  737. }
  738. struct tgsi_instruction_ext_texture
  739. tgsi_default_instruction_ext_texture( void )
  740. {
  741. struct tgsi_instruction_ext_texture instruction_ext_texture;
  742. instruction_ext_texture.Type = TGSI_INSTRUCTION_EXT_TYPE_TEXTURE;
  743. instruction_ext_texture.Texture = TGSI_TEXTURE_UNKNOWN;
  744. instruction_ext_texture.Padding = 0;
  745. instruction_ext_texture.Extended = 0;
  746. return instruction_ext_texture;
  747. }
  748. unsigned
  749. tgsi_compare_instruction_ext_texture(
  750. struct tgsi_instruction_ext_texture a,
  751. struct tgsi_instruction_ext_texture b )
  752. {
  753. a.Padding = b.Padding = 0;
  754. a.Extended = b.Extended = 0;
  755. return compare32(&a, &b);
  756. }
  757. struct tgsi_instruction_ext_texture
  758. tgsi_build_instruction_ext_texture(
  759. unsigned texture,
  760. struct tgsi_token *prev_token,
  761. struct tgsi_instruction *instruction,
  762. struct tgsi_header *header )
  763. {
  764. struct tgsi_instruction_ext_texture instruction_ext_texture;
  765. instruction_ext_texture = tgsi_default_instruction_ext_texture();
  766. instruction_ext_texture.Texture = texture;
  767. prev_token->Extended = 1;
  768. instruction_grow( instruction, header );
  769. return instruction_ext_texture;
  770. }
  771. struct tgsi_src_register
  772. tgsi_default_src_register( void )
  773. {
  774. struct tgsi_src_register src_register;
  775. src_register.File = TGSI_FILE_NULL;
  776. src_register.SwizzleX = TGSI_SWIZZLE_X;
  777. src_register.SwizzleY = TGSI_SWIZZLE_Y;
  778. src_register.SwizzleZ = TGSI_SWIZZLE_Z;
  779. src_register.SwizzleW = TGSI_SWIZZLE_W;
  780. src_register.Negate = 0;
  781. src_register.Indirect = 0;
  782. src_register.Dimension = 0;
  783. src_register.Index = 0;
  784. src_register.Extended = 0;
  785. return src_register;
  786. }
  787. struct tgsi_src_register
  788. tgsi_build_src_register(
  789. unsigned file,
  790. unsigned swizzle_x,
  791. unsigned swizzle_y,
  792. unsigned swizzle_z,
  793. unsigned swizzle_w,
  794. unsigned negate,
  795. unsigned indirect,
  796. unsigned dimension,
  797. int index,
  798. struct tgsi_instruction *instruction,
  799. struct tgsi_header *header )
  800. {
  801. struct tgsi_src_register src_register;
  802. assert( file <= TGSI_FILE_IMMEDIATE );
  803. assert( swizzle_x <= TGSI_SWIZZLE_W );
  804. assert( swizzle_y <= TGSI_SWIZZLE_W );
  805. assert( swizzle_z <= TGSI_SWIZZLE_W );
  806. assert( swizzle_w <= TGSI_SWIZZLE_W );
  807. assert( negate <= 1 );
  808. assert( index >= -0x8000 && index <= 0x7FFF );
  809. src_register = tgsi_default_src_register();
  810. src_register.File = file;
  811. src_register.SwizzleX = swizzle_x;
  812. src_register.SwizzleY = swizzle_y;
  813. src_register.SwizzleZ = swizzle_z;
  814. src_register.SwizzleW = swizzle_w;
  815. src_register.Negate = negate;
  816. src_register.Indirect = indirect;
  817. src_register.Dimension = dimension;
  818. src_register.Index = index;
  819. instruction_grow( instruction, header );
  820. return src_register;
  821. }
  822. struct tgsi_full_src_register
  823. tgsi_default_full_src_register( void )
  824. {
  825. struct tgsi_full_src_register full_src_register;
  826. full_src_register.SrcRegister = tgsi_default_src_register();
  827. full_src_register.SrcRegisterExtSwz = tgsi_default_src_register_ext_swz();
  828. full_src_register.SrcRegisterExtMod = tgsi_default_src_register_ext_mod();
  829. full_src_register.SrcRegisterInd = tgsi_default_src_register();
  830. full_src_register.SrcRegisterDim = tgsi_default_dimension();
  831. full_src_register.SrcRegisterDimInd = tgsi_default_src_register();
  832. return full_src_register;
  833. }
  834. struct tgsi_src_register_ext_swz
  835. tgsi_default_src_register_ext_swz( void )
  836. {
  837. struct tgsi_src_register_ext_swz src_register_ext_swz;
  838. src_register_ext_swz.Type = TGSI_SRC_REGISTER_EXT_TYPE_SWZ;
  839. src_register_ext_swz.ExtSwizzleX = TGSI_EXTSWIZZLE_X;
  840. src_register_ext_swz.ExtSwizzleY = TGSI_EXTSWIZZLE_Y;
  841. src_register_ext_swz.ExtSwizzleZ = TGSI_EXTSWIZZLE_Z;
  842. src_register_ext_swz.ExtSwizzleW = TGSI_EXTSWIZZLE_W;
  843. src_register_ext_swz.NegateX = 0;
  844. src_register_ext_swz.NegateY = 0;
  845. src_register_ext_swz.NegateZ = 0;
  846. src_register_ext_swz.NegateW = 0;
  847. src_register_ext_swz.Padding = 0;
  848. src_register_ext_swz.Extended = 0;
  849. return src_register_ext_swz;
  850. }
  851. unsigned
  852. tgsi_compare_src_register_ext_swz(
  853. struct tgsi_src_register_ext_swz a,
  854. struct tgsi_src_register_ext_swz b )
  855. {
  856. a.Padding = b.Padding = 0;
  857. a.Extended = b.Extended = 0;
  858. return compare32(&a, &b);
  859. }
  860. struct tgsi_src_register_ext_swz
  861. tgsi_build_src_register_ext_swz(
  862. unsigned ext_swizzle_x,
  863. unsigned ext_swizzle_y,
  864. unsigned ext_swizzle_z,
  865. unsigned ext_swizzle_w,
  866. unsigned negate_x,
  867. unsigned negate_y,
  868. unsigned negate_z,
  869. unsigned negate_w,
  870. struct tgsi_token *prev_token,
  871. struct tgsi_instruction *instruction,
  872. struct tgsi_header *header )
  873. {
  874. struct tgsi_src_register_ext_swz src_register_ext_swz;
  875. assert( ext_swizzle_x <= TGSI_EXTSWIZZLE_ONE );
  876. assert( ext_swizzle_y <= TGSI_EXTSWIZZLE_ONE );
  877. assert( ext_swizzle_z <= TGSI_EXTSWIZZLE_ONE );
  878. assert( ext_swizzle_w <= TGSI_EXTSWIZZLE_ONE );
  879. assert( negate_x <= 1 );
  880. assert( negate_y <= 1 );
  881. assert( negate_z <= 1 );
  882. assert( negate_w <= 1 );
  883. src_register_ext_swz = tgsi_default_src_register_ext_swz();
  884. src_register_ext_swz.ExtSwizzleX = ext_swizzle_x;
  885. src_register_ext_swz.ExtSwizzleY = ext_swizzle_y;
  886. src_register_ext_swz.ExtSwizzleZ = ext_swizzle_z;
  887. src_register_ext_swz.ExtSwizzleW = ext_swizzle_w;
  888. src_register_ext_swz.NegateX = negate_x;
  889. src_register_ext_swz.NegateY = negate_y;
  890. src_register_ext_swz.NegateZ = negate_z;
  891. src_register_ext_swz.NegateW = negate_w;
  892. prev_token->Extended = 1;
  893. instruction_grow( instruction, header );
  894. return src_register_ext_swz;
  895. }
  896. struct tgsi_src_register_ext_mod
  897. tgsi_default_src_register_ext_mod( void )
  898. {
  899. struct tgsi_src_register_ext_mod src_register_ext_mod;
  900. src_register_ext_mod.Type = TGSI_SRC_REGISTER_EXT_TYPE_MOD;
  901. src_register_ext_mod.Complement = 0;
  902. src_register_ext_mod.Bias = 0;
  903. src_register_ext_mod.Scale2X = 0;
  904. src_register_ext_mod.Absolute = 0;
  905. src_register_ext_mod.Negate = 0;
  906. src_register_ext_mod.Padding = 0;
  907. src_register_ext_mod.Extended = 0;
  908. return src_register_ext_mod;
  909. }
  910. unsigned
  911. tgsi_compare_src_register_ext_mod(
  912. struct tgsi_src_register_ext_mod a,
  913. struct tgsi_src_register_ext_mod b )
  914. {
  915. a.Padding = b.Padding = 0;
  916. a.Extended = b.Extended = 0;
  917. return compare32(&a, &b);
  918. }
  919. struct tgsi_src_register_ext_mod
  920. tgsi_build_src_register_ext_mod(
  921. unsigned complement,
  922. unsigned bias,
  923. unsigned scale_2x,
  924. unsigned absolute,
  925. unsigned negate,
  926. struct tgsi_token *prev_token,
  927. struct tgsi_instruction *instruction,
  928. struct tgsi_header *header )
  929. {
  930. struct tgsi_src_register_ext_mod src_register_ext_mod;
  931. assert( complement <= 1 );
  932. assert( bias <= 1 );
  933. assert( scale_2x <= 1 );
  934. assert( absolute <= 1 );
  935. assert( negate <= 1 );
  936. src_register_ext_mod = tgsi_default_src_register_ext_mod();
  937. src_register_ext_mod.Complement = complement;
  938. src_register_ext_mod.Bias = bias;
  939. src_register_ext_mod.Scale2X = scale_2x;
  940. src_register_ext_mod.Absolute = absolute;
  941. src_register_ext_mod.Negate = negate;
  942. prev_token->Extended = 1;
  943. instruction_grow( instruction, header );
  944. return src_register_ext_mod;
  945. }
  946. struct tgsi_dimension
  947. tgsi_default_dimension( void )
  948. {
  949. struct tgsi_dimension dimension;
  950. dimension.Indirect = 0;
  951. dimension.Dimension = 0;
  952. dimension.Padding = 0;
  953. dimension.Index = 0;
  954. dimension.Extended = 0;
  955. return dimension;
  956. }
  957. struct tgsi_dimension
  958. tgsi_build_dimension(
  959. unsigned indirect,
  960. unsigned index,
  961. struct tgsi_instruction *instruction,
  962. struct tgsi_header *header )
  963. {
  964. struct tgsi_dimension dimension;
  965. dimension = tgsi_default_dimension();
  966. dimension.Indirect = indirect;
  967. dimension.Index = index;
  968. instruction_grow( instruction, header );
  969. return dimension;
  970. }
  971. struct tgsi_dst_register
  972. tgsi_default_dst_register( void )
  973. {
  974. struct tgsi_dst_register dst_register;
  975. dst_register.File = TGSI_FILE_NULL;
  976. dst_register.WriteMask = TGSI_WRITEMASK_XYZW;
  977. dst_register.Indirect = 0;
  978. dst_register.Dimension = 0;
  979. dst_register.Index = 0;
  980. dst_register.Padding = 0;
  981. dst_register.Extended = 0;
  982. return dst_register;
  983. }
  984. struct tgsi_dst_register
  985. tgsi_build_dst_register(
  986. unsigned file,
  987. unsigned mask,
  988. int index,
  989. struct tgsi_instruction *instruction,
  990. struct tgsi_header *header )
  991. {
  992. struct tgsi_dst_register dst_register;
  993. assert( file <= TGSI_FILE_IMMEDIATE );
  994. assert( mask <= TGSI_WRITEMASK_XYZW );
  995. assert( index >= -32768 && index <= 32767 );
  996. dst_register = tgsi_default_dst_register();
  997. dst_register.File = file;
  998. dst_register.WriteMask = mask;
  999. dst_register.Index = index;
  1000. instruction_grow( instruction, header );
  1001. return dst_register;
  1002. }
  1003. struct tgsi_full_dst_register
  1004. tgsi_default_full_dst_register( void )
  1005. {
  1006. struct tgsi_full_dst_register full_dst_register;
  1007. full_dst_register.DstRegister = tgsi_default_dst_register();
  1008. full_dst_register.DstRegisterExtConcode =
  1009. tgsi_default_dst_register_ext_concode();
  1010. full_dst_register.DstRegisterExtModulate =
  1011. tgsi_default_dst_register_ext_modulate();
  1012. return full_dst_register;
  1013. }
  1014. struct tgsi_dst_register_ext_concode
  1015. tgsi_default_dst_register_ext_concode( void )
  1016. {
  1017. struct tgsi_dst_register_ext_concode dst_register_ext_concode;
  1018. dst_register_ext_concode.Type = TGSI_DST_REGISTER_EXT_TYPE_CONDCODE;
  1019. dst_register_ext_concode.CondMask = TGSI_CC_TR;
  1020. dst_register_ext_concode.CondSwizzleX = TGSI_SWIZZLE_X;
  1021. dst_register_ext_concode.CondSwizzleY = TGSI_SWIZZLE_Y;
  1022. dst_register_ext_concode.CondSwizzleZ = TGSI_SWIZZLE_Z;
  1023. dst_register_ext_concode.CondSwizzleW = TGSI_SWIZZLE_W;
  1024. dst_register_ext_concode.CondSrcIndex = 0;
  1025. dst_register_ext_concode.Padding = 0;
  1026. dst_register_ext_concode.Extended = 0;
  1027. return dst_register_ext_concode;
  1028. }
  1029. unsigned
  1030. tgsi_compare_dst_register_ext_concode(
  1031. struct tgsi_dst_register_ext_concode a,
  1032. struct tgsi_dst_register_ext_concode b )
  1033. {
  1034. a.Padding = b.Padding = 0;
  1035. a.Extended = b.Extended = 0;
  1036. return compare32(&a, &b);
  1037. }
  1038. struct tgsi_dst_register_ext_concode
  1039. tgsi_build_dst_register_ext_concode(
  1040. unsigned cc,
  1041. unsigned swizzle_x,
  1042. unsigned swizzle_y,
  1043. unsigned swizzle_z,
  1044. unsigned swizzle_w,
  1045. int index,
  1046. struct tgsi_token *prev_token,
  1047. struct tgsi_instruction *instruction,
  1048. struct tgsi_header *header )
  1049. {
  1050. struct tgsi_dst_register_ext_concode dst_register_ext_concode;
  1051. assert( cc <= TGSI_CC_FL );
  1052. assert( swizzle_x <= TGSI_SWIZZLE_W );
  1053. assert( swizzle_y <= TGSI_SWIZZLE_W );
  1054. assert( swizzle_z <= TGSI_SWIZZLE_W );
  1055. assert( swizzle_w <= TGSI_SWIZZLE_W );
  1056. assert( index >= -32768 && index <= 32767 );
  1057. dst_register_ext_concode = tgsi_default_dst_register_ext_concode();
  1058. dst_register_ext_concode.CondMask = cc;
  1059. dst_register_ext_concode.CondSwizzleX = swizzle_x;
  1060. dst_register_ext_concode.CondSwizzleY = swizzle_y;
  1061. dst_register_ext_concode.CondSwizzleZ = swizzle_z;
  1062. dst_register_ext_concode.CondSwizzleW = swizzle_w;
  1063. dst_register_ext_concode.CondSrcIndex = index;
  1064. prev_token->Extended = 1;
  1065. instruction_grow( instruction, header );
  1066. return dst_register_ext_concode;
  1067. }
  1068. struct tgsi_dst_register_ext_modulate
  1069. tgsi_default_dst_register_ext_modulate( void )
  1070. {
  1071. struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
  1072. dst_register_ext_modulate.Type = TGSI_DST_REGISTER_EXT_TYPE_MODULATE;
  1073. dst_register_ext_modulate.Modulate = TGSI_MODULATE_1X;
  1074. dst_register_ext_modulate.Padding = 0;
  1075. dst_register_ext_modulate.Extended = 0;
  1076. return dst_register_ext_modulate;
  1077. }
  1078. unsigned
  1079. tgsi_compare_dst_register_ext_modulate(
  1080. struct tgsi_dst_register_ext_modulate a,
  1081. struct tgsi_dst_register_ext_modulate b )
  1082. {
  1083. a.Padding = b.Padding = 0;
  1084. a.Extended = b.Extended = 0;
  1085. return compare32(&a, &b);
  1086. }
  1087. struct tgsi_dst_register_ext_modulate
  1088. tgsi_build_dst_register_ext_modulate(
  1089. unsigned modulate,
  1090. struct tgsi_token *prev_token,
  1091. struct tgsi_instruction *instruction,
  1092. struct tgsi_header *header )
  1093. {
  1094. struct tgsi_dst_register_ext_modulate dst_register_ext_modulate;
  1095. assert( modulate <= TGSI_MODULATE_EIGHTH );
  1096. dst_register_ext_modulate = tgsi_default_dst_register_ext_modulate();
  1097. dst_register_ext_modulate.Modulate = modulate;
  1098. prev_token->Extended = 1;
  1099. instruction_grow( instruction, header );
  1100. return dst_register_ext_modulate;
  1101. }