1 /**************************************************************************
3 * Copyright 2009 VMware, Inc.
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 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.
26 **************************************************************************/
31 #include "pipe/p_compiler.h"
32 #include "pipe/p_shader_tokens.h"
33 #include "util/u_debug.h"
41 struct pipe_stream_output_info
;
43 /* Almost a tgsi_src_register, but we need to pull in the Absolute
44 * flag from the _ext token. Indirect flag always implies ADDR[0].
48 unsigned File
: 4; /* TGSI_FILE_ */
49 unsigned SwizzleX
: 2; /* TGSI_SWIZZLE_ */
50 unsigned SwizzleY
: 2; /* TGSI_SWIZZLE_ */
51 unsigned SwizzleZ
: 2; /* TGSI_SWIZZLE_ */
52 unsigned SwizzleW
: 2; /* TGSI_SWIZZLE_ */
53 unsigned Indirect
: 1; /* BOOL */
54 unsigned DimIndirect
: 1; /* BOOL */
55 unsigned Dimension
: 1; /* BOOL */
56 unsigned Absolute
: 1; /* BOOL */
57 unsigned Negate
: 1; /* BOOL */
58 unsigned IndirectFile
: 4; /* TGSI_FILE_ */
59 unsigned IndirectSwizzle
: 2; /* TGSI_SWIZZLE_ */
60 unsigned DimIndFile
: 4; /* TGSI_FILE_ */
61 unsigned DimIndSwizzle
: 2; /* TGSI_SWIZZLE_ */
62 int Index
: 16; /* SINT */
63 int IndirectIndex
: 16; /* SINT */
64 int DimensionIndex
: 16; /* SINT */
65 int DimIndIndex
: 16; /* SINT */
66 unsigned ArrayID
: 10; /* UINT */
69 /* Very similar to a tgsi_dst_register, removing unsupported fields
70 * and adding a Saturate flag. It's easier to push saturate into the
71 * destination register than to try and create a _SAT variant of each
72 * instruction function.
76 unsigned File
: 4; /* TGSI_FILE_ */
77 unsigned WriteMask
: 4; /* TGSI_WRITEMASK_ */
78 unsigned Indirect
: 1; /* BOOL */
79 unsigned DimIndirect
: 1; /* BOOL */
80 unsigned Dimension
: 1; /* BOOL */
81 unsigned Saturate
: 1; /* BOOL */
82 int Index
: 16; /* SINT */
83 int IndirectIndex
: 16; /* SINT */
84 unsigned IndirectFile
: 4; /* TGSI_FILE_ */
85 int IndirectSwizzle
: 2; /* TGSI_SWIZZLE_ */
86 unsigned DimIndFile
: 4; /* TGSI_FILE_ */
87 unsigned DimIndSwizzle
: 2; /* TGSI_SWIZZLE_ */
88 int DimensionIndex
: 16; /* SINT */
89 int DimIndIndex
: 16; /* SINT */
90 unsigned ArrayID
: 10; /* UINT */
96 ureg_create(enum pipe_shader_type processor
);
99 ureg_create_with_screen(enum pipe_shader_type processor
,
100 struct pipe_screen
*screen
);
102 const struct tgsi_token
*
103 ureg_finalize( struct ureg_program
* );
105 /* Create and return a shader:
108 ureg_create_shader( struct ureg_program
*,
109 struct pipe_context
*pipe
,
110 const struct pipe_stream_output_info
*so
);
113 ureg_set_next_shader_processor(struct ureg_program
*ureg
, unsigned processor
);
115 /* Alternately, return the built token stream and hand ownership of
116 * that memory to the caller:
118 const struct tgsi_token
*
119 ureg_get_tokens( struct ureg_program
*ureg
,
120 unsigned *nr_tokens
);
123 * Returns the number of currently declared outputs.
126 ureg_get_nr_outputs( const struct ureg_program
*ureg
);
129 /* Free the tokens created by ureg_get_tokens() */
130 void ureg_free_tokens( const struct tgsi_token
*tokens
);
134 ureg_destroy( struct ureg_program
* );
137 /***********************************************************************
138 * Convenience routine:
141 ureg_create_shader_with_so_and_destroy( struct ureg_program
*p
,
142 struct pipe_context
*pipe
,
143 const struct pipe_stream_output_info
*so
)
145 void *result
= ureg_create_shader( p
, pipe
, so
);
151 ureg_create_shader_and_destroy( struct ureg_program
*p
,
152 struct pipe_context
*pipe
)
154 return ureg_create_shader_with_so_and_destroy(p
, pipe
, NULL
);
158 /***********************************************************************
159 * Build shader properties:
163 ureg_property(struct ureg_program
*ureg
, unsigned name
, unsigned value
);
166 /***********************************************************************
167 * Build shader declarations:
171 ureg_DECL_fs_input_cyl_centroid_layout(struct ureg_program
*,
172 enum tgsi_semantic semantic_name
,
173 unsigned semantic_index
,
174 enum tgsi_interpolate_mode interp_mode
,
175 unsigned cylindrical_wrap
,
176 enum tgsi_interpolate_loc interp_location
,
180 unsigned array_size
);
183 ureg_DECL_fs_input_cyl_centroid(struct ureg_program
*,
184 enum tgsi_semantic semantic_name
,
185 unsigned semantic_index
,
186 enum tgsi_interpolate_mode interp_mode
,
187 unsigned cylindrical_wrap
,
188 enum tgsi_interpolate_loc interp_location
,
190 unsigned array_size
);
192 static inline struct ureg_src
193 ureg_DECL_fs_input_cyl(struct ureg_program
*ureg
,
194 enum tgsi_semantic semantic_name
,
195 unsigned semantic_index
,
196 enum tgsi_interpolate_mode interp_mode
,
197 unsigned cylindrical_wrap
)
199 return ureg_DECL_fs_input_cyl_centroid(ureg
,
204 TGSI_INTERPOLATE_LOC_CENTER
, 0, 1);
207 static inline struct ureg_src
208 ureg_DECL_fs_input(struct ureg_program
*ureg
,
209 enum tgsi_semantic semantic_name
,
210 unsigned semantic_index
,
211 enum tgsi_interpolate_mode interp_mode
)
213 return ureg_DECL_fs_input_cyl_centroid(ureg
,
217 0, TGSI_INTERPOLATE_LOC_CENTER
, 0, 1);
221 ureg_DECL_vs_input( struct ureg_program
*,
225 ureg_DECL_input_layout(struct ureg_program
*,
226 enum tgsi_semantic semantic_name
,
227 unsigned semantic_index
,
231 unsigned array_size
);
234 ureg_DECL_input(struct ureg_program
*,
235 enum tgsi_semantic semantic_name
,
236 unsigned semantic_index
,
238 unsigned array_size
);
241 ureg_DECL_system_value(struct ureg_program
*,
242 enum tgsi_semantic semantic_name
,
243 unsigned semantic_index
);
246 ureg_DECL_output_layout(struct ureg_program
*,
247 enum tgsi_semantic semantic_name
,
248 unsigned semantic_index
,
253 unsigned array_size
);
256 ureg_DECL_output_masked(struct ureg_program
*,
257 enum tgsi_semantic semantic_name
,
258 unsigned semantic_index
,
261 unsigned array_size
);
264 ureg_DECL_output(struct ureg_program
*,
265 enum tgsi_semantic semantic_name
,
266 unsigned semantic_index
);
269 ureg_DECL_output_array(struct ureg_program
*ureg
,
270 enum tgsi_semantic semantic_name
,
271 unsigned semantic_index
,
273 unsigned array_size
);
276 ureg_DECL_immediate( struct ureg_program
*,
281 ureg_DECL_immediate_f64( struct ureg_program
*,
286 ureg_DECL_immediate_uint( struct ureg_program
*,
291 ureg_DECL_immediate_block_uint( struct ureg_program
*,
296 ureg_DECL_immediate_int( struct ureg_program
*,
301 ureg_DECL_immediate_uint64( struct ureg_program
*,
306 ureg_DECL_immediate_int64( struct ureg_program
*,
311 ureg_DECL_constant2D(struct ureg_program
*ureg
,
317 ureg_DECL_constant( struct ureg_program
*,
321 ureg_DECL_hw_atomic(struct ureg_program
*ureg
,
328 ureg_DECL_temporary( struct ureg_program
* );
331 * Emit a temporary with the LOCAL declaration flag set. For use when
332 * the register value is not required to be preserved across
333 * subroutine boundaries.
336 ureg_DECL_local_temporary( struct ureg_program
* );
339 * Declare "size" continuous temporary registers.
342 ureg_DECL_array_temporary( struct ureg_program
*,
347 ureg_release_temporary( struct ureg_program
*ureg
,
348 struct ureg_dst tmp
);
351 ureg_DECL_address( struct ureg_program
* );
353 /* Supply an index to the sampler declaration as this is the hook to
354 * the external pipe_sampler state. Users of this function probably
355 * don't want just any sampler, but a specific one which they've set
356 * up state for in the context.
359 ureg_DECL_sampler( struct ureg_program
*,
363 ureg_DECL_sampler_view(struct ureg_program
*,
365 enum tgsi_texture_type target
,
366 enum tgsi_return_type return_type_x
,
367 enum tgsi_return_type return_type_y
,
368 enum tgsi_return_type return_type_z
,
369 enum tgsi_return_type return_type_w
);
372 ureg_DECL_image(struct ureg_program
*ureg
,
374 enum tgsi_texture_type target
,
380 ureg_DECL_buffer(struct ureg_program
*ureg
, unsigned nr
, bool atomic
);
383 ureg_DECL_memory(struct ureg_program
*ureg
, unsigned memory_type
);
385 static inline struct ureg_src
386 ureg_imm4f( struct ureg_program
*ureg
,
395 return ureg_DECL_immediate( ureg
, v
, 4 );
398 static inline struct ureg_src
399 ureg_imm3f( struct ureg_program
*ureg
,
407 return ureg_DECL_immediate( ureg
, v
, 3 );
410 static inline struct ureg_src
411 ureg_imm2f( struct ureg_program
*ureg
,
417 return ureg_DECL_immediate( ureg
, v
, 2 );
420 static inline struct ureg_src
421 ureg_imm1f( struct ureg_program
*ureg
,
426 return ureg_DECL_immediate( ureg
, v
, 1 );
429 static inline struct ureg_src
430 ureg_imm4u( struct ureg_program
*ureg
,
431 unsigned a
, unsigned b
,
432 unsigned c
, unsigned d
)
439 return ureg_DECL_immediate_uint( ureg
, v
, 4 );
442 static inline struct ureg_src
443 ureg_imm3u( struct ureg_program
*ureg
,
444 unsigned a
, unsigned b
,
451 return ureg_DECL_immediate_uint( ureg
, v
, 3 );
454 static inline struct ureg_src
455 ureg_imm2u( struct ureg_program
*ureg
,
456 unsigned a
, unsigned b
)
461 return ureg_DECL_immediate_uint( ureg
, v
, 2 );
464 static inline struct ureg_src
465 ureg_imm1u( struct ureg_program
*ureg
,
468 return ureg_DECL_immediate_uint( ureg
, &a
, 1 );
471 static inline struct ureg_src
472 ureg_imm4i( struct ureg_program
*ureg
,
481 return ureg_DECL_immediate_int( ureg
, v
, 4 );
484 static inline struct ureg_src
485 ureg_imm3i( struct ureg_program
*ureg
,
493 return ureg_DECL_immediate_int( ureg
, v
, 3 );
496 static inline struct ureg_src
497 ureg_imm2i( struct ureg_program
*ureg
,
503 return ureg_DECL_immediate_int( ureg
, v
, 2 );
506 static inline struct ureg_src
507 ureg_imm1i( struct ureg_program
*ureg
,
510 return ureg_DECL_immediate_int( ureg
, &a
, 1 );
513 /* Where the destination register has a valid file, but an empty
516 static inline boolean
517 ureg_dst_is_empty( struct ureg_dst dst
)
519 return dst
.File
!= TGSI_FILE_NULL
&&
523 /***********************************************************************
524 * Functions for patching up labels
528 /* Will return a number which can be used in a label to point to the
529 * next instruction to be emitted.
532 ureg_get_instruction_number( struct ureg_program
*ureg
);
535 /* Patch a given label (expressed as a token number) to point to a
536 * given instruction (expressed as an instruction number).
538 * Labels are obtained from instruction emitters, eg ureg_CAL().
539 * Instruction numbers are obtained from ureg_get_instruction_number(),
543 ureg_fixup_label(struct ureg_program
*ureg
,
544 unsigned label_token
,
545 unsigned instruction_number
);
548 /* Generic instruction emitter. Use if you need to pass the opcode as
549 * a parameter, rather than using the emit_OP() variants below.
552 ureg_insn(struct ureg_program
*ureg
,
554 const struct ureg_dst
*dst
,
556 const struct ureg_src
*src
,
562 ureg_tex_insn(struct ureg_program
*ureg
,
564 const struct ureg_dst
*dst
,
566 enum tgsi_texture_type target
,
567 enum tgsi_return_type return_type
,
568 const struct tgsi_texture_offset
*texoffsets
,
570 const struct ureg_src
*src
,
575 ureg_memory_insn(struct ureg_program
*ureg
,
577 const struct ureg_dst
*dst
,
579 const struct ureg_src
*src
,
585 /***********************************************************************
586 * Internal instruction helpers, don't call these directly:
589 struct ureg_emit_insn_result
{
590 unsigned insn_token
; /*< Used to fixup insn size. */
591 unsigned extended_token
; /*< Used to set the Extended bit, usually the same as insn_token. */
594 struct ureg_emit_insn_result
595 ureg_emit_insn(struct ureg_program
*ureg
,
603 ureg_emit_label(struct ureg_program
*ureg
,
605 unsigned *label_token
);
608 ureg_emit_texture(struct ureg_program
*ureg
,
610 enum tgsi_texture_type target
,
611 enum tgsi_return_type return_type
,
612 unsigned num_offsets
);
615 ureg_emit_texture_offset(struct ureg_program
*ureg
,
616 const struct tgsi_texture_offset
*offset
);
619 ureg_emit_memory(struct ureg_program
*ureg
,
626 ureg_emit_dst( struct ureg_program
*ureg
,
627 struct ureg_dst dst
);
630 ureg_emit_src( struct ureg_program
*ureg
,
631 struct ureg_src src
);
634 ureg_fixup_insn_size(struct ureg_program
*ureg
,
639 static inline void ureg_##op( struct ureg_program *ureg ) \
641 unsigned opcode = TGSI_OPCODE_##op; \
642 struct ureg_emit_insn_result insn; \
643 insn = ureg_emit_insn(ureg, \
649 ureg_fixup_insn_size( ureg, insn.insn_token ); \
653 static inline void ureg_##op( struct ureg_program *ureg, \
654 struct ureg_src src ) \
656 unsigned opcode = TGSI_OPCODE_##op; \
657 struct ureg_emit_insn_result insn; \
658 insn = ureg_emit_insn(ureg, \
664 ureg_emit_src( ureg, src ); \
665 ureg_fixup_insn_size( ureg, insn.insn_token ); \
668 #define OP00_LBL( op ) \
669 static inline void ureg_##op( struct ureg_program *ureg, \
670 unsigned *label_token ) \
672 unsigned opcode = TGSI_OPCODE_##op; \
673 struct ureg_emit_insn_result insn; \
674 insn = ureg_emit_insn(ureg, \
680 ureg_emit_label( ureg, insn.extended_token, label_token ); \
681 ureg_fixup_insn_size( ureg, insn.insn_token ); \
684 #define OP01_LBL( op ) \
685 static inline void ureg_##op( struct ureg_program *ureg, \
686 struct ureg_src src, \
687 unsigned *label_token ) \
689 unsigned opcode = TGSI_OPCODE_##op; \
690 struct ureg_emit_insn_result insn; \
691 insn = ureg_emit_insn(ureg, \
697 ureg_emit_label( ureg, insn.extended_token, label_token ); \
698 ureg_emit_src( ureg, src ); \
699 ureg_fixup_insn_size( ureg, insn.insn_token ); \
703 static inline void ureg_##op( struct ureg_program *ureg, \
704 struct ureg_dst dst ) \
706 unsigned opcode = TGSI_OPCODE_##op; \
707 struct ureg_emit_insn_result insn; \
708 if (ureg_dst_is_empty(dst)) \
710 insn = ureg_emit_insn(ureg, \
716 ureg_emit_dst( ureg, dst ); \
717 ureg_fixup_insn_size( ureg, insn.insn_token ); \
722 static inline void ureg_##op( struct ureg_program *ureg, \
723 struct ureg_dst dst, \
724 struct ureg_src src ) \
726 unsigned opcode = TGSI_OPCODE_##op; \
727 struct ureg_emit_insn_result insn; \
728 if (ureg_dst_is_empty(dst)) \
730 insn = ureg_emit_insn(ureg, \
736 ureg_emit_dst( ureg, dst ); \
737 ureg_emit_src( ureg, src ); \
738 ureg_fixup_insn_size( ureg, insn.insn_token ); \
742 static inline void ureg_##op( struct ureg_program *ureg, \
743 struct ureg_dst dst, \
744 struct ureg_src src0, \
745 struct ureg_src src1 ) \
747 unsigned opcode = TGSI_OPCODE_##op; \
748 struct ureg_emit_insn_result insn; \
749 if (ureg_dst_is_empty(dst)) \
751 insn = ureg_emit_insn(ureg, \
757 ureg_emit_dst( ureg, dst ); \
758 ureg_emit_src( ureg, src0 ); \
759 ureg_emit_src( ureg, src1 ); \
760 ureg_fixup_insn_size( ureg, insn.insn_token ); \
763 #define OP12_TEX( op ) \
764 static inline void ureg_##op( struct ureg_program *ureg, \
765 struct ureg_dst dst, \
766 enum tgsi_texture_type target, \
767 struct ureg_src src0, \
768 struct ureg_src src1 ) \
770 unsigned opcode = TGSI_OPCODE_##op; \
771 enum tgsi_return_type return_type = TGSI_RETURN_TYPE_UNKNOWN; \
772 struct ureg_emit_insn_result insn; \
773 if (ureg_dst_is_empty(dst)) \
775 insn = ureg_emit_insn(ureg, \
781 ureg_emit_texture( ureg, insn.extended_token, target, \
783 ureg_emit_dst( ureg, dst ); \
784 ureg_emit_src( ureg, src0 ); \
785 ureg_emit_src( ureg, src1 ); \
786 ureg_fixup_insn_size( ureg, insn.insn_token ); \
790 static inline void ureg_##op( struct ureg_program *ureg, \
791 struct ureg_dst dst, \
792 struct ureg_src src0, \
793 struct ureg_src src1, \
794 struct ureg_src src2 ) \
796 unsigned opcode = TGSI_OPCODE_##op; \
797 struct ureg_emit_insn_result insn; \
798 if (ureg_dst_is_empty(dst)) \
800 insn = ureg_emit_insn(ureg, \
806 ureg_emit_dst( ureg, dst ); \
807 ureg_emit_src( ureg, src0 ); \
808 ureg_emit_src( ureg, src1 ); \
809 ureg_emit_src( ureg, src2 ); \
810 ureg_fixup_insn_size( ureg, insn.insn_token ); \
813 #define OP14_TEX( op ) \
814 static inline void ureg_##op( struct ureg_program *ureg, \
815 struct ureg_dst dst, \
816 enum tgsi_texture_type target, \
817 struct ureg_src src0, \
818 struct ureg_src src1, \
819 struct ureg_src src2, \
820 struct ureg_src src3 ) \
822 unsigned opcode = TGSI_OPCODE_##op; \
823 enum tgsi_return_type return_type = TGSI_RETURN_TYPE_UNKNOWN; \
824 struct ureg_emit_insn_result insn; \
825 if (ureg_dst_is_empty(dst)) \
827 insn = ureg_emit_insn(ureg, \
833 ureg_emit_texture( ureg, insn.extended_token, target, \
835 ureg_emit_dst( ureg, dst ); \
836 ureg_emit_src( ureg, src0 ); \
837 ureg_emit_src( ureg, src1 ); \
838 ureg_emit_src( ureg, src2 ); \
839 ureg_emit_src( ureg, src3 ); \
840 ureg_fixup_insn_size( ureg, insn.insn_token ); \
843 /* Use a template include to generate a correctly-typed ureg_OP()
844 * function for each TGSI opcode:
846 #include "tgsi_opcode_tmp.h"
849 /***********************************************************************
850 * Inline helpers for manipulating register structs:
852 static inline struct ureg_src
853 ureg_negate( struct ureg_src reg
)
855 assert(reg
.File
!= TGSI_FILE_NULL
);
860 static inline struct ureg_src
861 ureg_abs( struct ureg_src reg
)
863 assert(reg
.File
!= TGSI_FILE_NULL
);
869 static inline struct ureg_src
870 ureg_swizzle( struct ureg_src reg
,
871 int x
, int y
, int z
, int w
)
873 unsigned swz
= ( (reg
.SwizzleX
<< 0) |
874 (reg
.SwizzleY
<< 2) |
875 (reg
.SwizzleZ
<< 4) |
876 (reg
.SwizzleW
<< 6));
878 assert(reg
.File
!= TGSI_FILE_NULL
);
884 reg
.SwizzleX
= (swz
>> (x
*2)) & 0x3;
885 reg
.SwizzleY
= (swz
>> (y
*2)) & 0x3;
886 reg
.SwizzleZ
= (swz
>> (z
*2)) & 0x3;
887 reg
.SwizzleW
= (swz
>> (w
*2)) & 0x3;
891 static inline struct ureg_src
892 ureg_scalar( struct ureg_src reg
, int x
)
894 return ureg_swizzle(reg
, x
, x
, x
, x
);
897 static inline struct ureg_dst
898 ureg_writemask( struct ureg_dst reg
,
901 assert(reg
.File
!= TGSI_FILE_NULL
);
902 reg
.WriteMask
&= writemask
;
906 static inline struct ureg_dst
907 ureg_saturate( struct ureg_dst reg
)
909 assert(reg
.File
!= TGSI_FILE_NULL
);
914 static inline struct ureg_dst
915 ureg_dst_indirect( struct ureg_dst reg
, struct ureg_src addr
)
917 assert(reg
.File
!= TGSI_FILE_NULL
);
919 reg
.IndirectFile
= addr
.File
;
920 reg
.IndirectIndex
= addr
.Index
;
921 reg
.IndirectSwizzle
= addr
.SwizzleX
;
925 static inline struct ureg_src
926 ureg_src_indirect( struct ureg_src reg
, struct ureg_src addr
)
928 assert(reg
.File
!= TGSI_FILE_NULL
);
930 reg
.IndirectFile
= addr
.File
;
931 reg
.IndirectIndex
= addr
.Index
;
932 reg
.IndirectSwizzle
= addr
.SwizzleX
;
936 static inline struct ureg_dst
937 ureg_dst_dimension( struct ureg_dst reg
, int index
)
939 assert(reg
.File
!= TGSI_FILE_NULL
);
942 reg
.DimensionIndex
= index
;
946 static inline struct ureg_src
947 ureg_src_dimension( struct ureg_src reg
, int index
)
949 assert(reg
.File
!= TGSI_FILE_NULL
);
952 reg
.DimensionIndex
= index
;
956 static inline struct ureg_dst
957 ureg_dst_dimension_indirect( struct ureg_dst reg
, struct ureg_src addr
,
960 assert(reg
.File
!= TGSI_FILE_NULL
);
963 reg
.DimensionIndex
= index
;
964 reg
.DimIndFile
= addr
.File
;
965 reg
.DimIndIndex
= addr
.Index
;
966 reg
.DimIndSwizzle
= addr
.SwizzleX
;
970 static inline struct ureg_src
971 ureg_src_dimension_indirect( struct ureg_src reg
, struct ureg_src addr
,
974 assert(reg
.File
!= TGSI_FILE_NULL
);
977 reg
.DimensionIndex
= index
;
978 reg
.DimIndFile
= addr
.File
;
979 reg
.DimIndIndex
= addr
.Index
;
980 reg
.DimIndSwizzle
= addr
.SwizzleX
;
984 static inline struct ureg_src
985 ureg_src_array_offset(struct ureg_src reg
, int offset
)
991 static inline struct ureg_dst
992 ureg_dst_array_offset( struct ureg_dst reg
, int offset
)
998 static inline struct ureg_dst
999 ureg_dst_array_register(unsigned file
,
1003 struct ureg_dst dst
;
1006 dst
.WriteMask
= TGSI_WRITEMASK_XYZW
;
1008 dst
.IndirectFile
= TGSI_FILE_NULL
;
1009 dst
.IndirectIndex
= 0;
1010 dst
.IndirectSwizzle
= 0;
1014 dst
.DimensionIndex
= 0;
1015 dst
.DimIndirect
= 0;
1016 dst
.DimIndFile
= TGSI_FILE_NULL
;
1017 dst
.DimIndIndex
= 0;
1018 dst
.DimIndSwizzle
= 0;
1019 dst
.ArrayID
= array_id
;
1024 static inline struct ureg_dst
1025 ureg_dst_register(unsigned file
,
1028 return ureg_dst_array_register(file
, index
, 0);
1031 static inline struct ureg_dst
1032 ureg_dst( struct ureg_src src
)
1034 struct ureg_dst dst
;
1036 dst
.File
= src
.File
;
1037 dst
.WriteMask
= TGSI_WRITEMASK_XYZW
;
1038 dst
.IndirectFile
= src
.IndirectFile
;
1039 dst
.Indirect
= src
.Indirect
;
1040 dst
.IndirectIndex
= src
.IndirectIndex
;
1041 dst
.IndirectSwizzle
= src
.IndirectSwizzle
;
1043 dst
.Index
= src
.Index
;
1044 dst
.Dimension
= src
.Dimension
;
1045 dst
.DimensionIndex
= src
.DimensionIndex
;
1046 dst
.DimIndirect
= src
.DimIndirect
;
1047 dst
.DimIndFile
= src
.DimIndFile
;
1048 dst
.DimIndIndex
= src
.DimIndIndex
;
1049 dst
.DimIndSwizzle
= src
.DimIndSwizzle
;
1050 dst
.ArrayID
= src
.ArrayID
;
1055 static inline struct ureg_src
1056 ureg_src_array_register(unsigned file
,
1060 struct ureg_src src
;
1063 src
.SwizzleX
= TGSI_SWIZZLE_X
;
1064 src
.SwizzleY
= TGSI_SWIZZLE_Y
;
1065 src
.SwizzleZ
= TGSI_SWIZZLE_Z
;
1066 src
.SwizzleW
= TGSI_SWIZZLE_W
;
1068 src
.IndirectFile
= TGSI_FILE_NULL
;
1069 src
.IndirectIndex
= 0;
1070 src
.IndirectSwizzle
= 0;
1075 src
.DimensionIndex
= 0;
1076 src
.DimIndirect
= 0;
1077 src
.DimIndFile
= TGSI_FILE_NULL
;
1078 src
.DimIndIndex
= 0;
1079 src
.DimIndSwizzle
= 0;
1080 src
.ArrayID
= array_id
;
1085 static inline struct ureg_src
1086 ureg_src_register(unsigned file
,
1089 return ureg_src_array_register(file
, index
, 0);
1092 static inline struct ureg_src
1093 ureg_src( struct ureg_dst dst
)
1095 struct ureg_src src
;
1097 src
.File
= dst
.File
;
1098 src
.SwizzleX
= TGSI_SWIZZLE_X
;
1099 src
.SwizzleY
= TGSI_SWIZZLE_Y
;
1100 src
.SwizzleZ
= TGSI_SWIZZLE_Z
;
1101 src
.SwizzleW
= TGSI_SWIZZLE_W
;
1102 src
.Indirect
= dst
.Indirect
;
1103 src
.IndirectFile
= dst
.IndirectFile
;
1104 src
.IndirectIndex
= dst
.IndirectIndex
;
1105 src
.IndirectSwizzle
= dst
.IndirectSwizzle
;
1107 src
.Index
= dst
.Index
;
1109 src
.Dimension
= dst
.Dimension
;
1110 src
.DimensionIndex
= dst
.DimensionIndex
;
1111 src
.DimIndirect
= dst
.DimIndirect
;
1112 src
.DimIndFile
= dst
.DimIndFile
;
1113 src
.DimIndIndex
= dst
.DimIndIndex
;
1114 src
.DimIndSwizzle
= dst
.DimIndSwizzle
;
1115 src
.ArrayID
= dst
.ArrayID
;
1122 static inline struct ureg_dst
1123 ureg_dst_undef( void )
1125 struct ureg_dst dst
;
1127 dst
.File
= TGSI_FILE_NULL
;
1130 dst
.IndirectFile
= TGSI_FILE_NULL
;
1131 dst
.IndirectIndex
= 0;
1132 dst
.IndirectSwizzle
= 0;
1136 dst
.DimensionIndex
= 0;
1137 dst
.DimIndirect
= 0;
1138 dst
.DimIndFile
= TGSI_FILE_NULL
;
1139 dst
.DimIndIndex
= 0;
1140 dst
.DimIndSwizzle
= 0;
1146 static inline struct ureg_src
1147 ureg_src_undef( void )
1149 struct ureg_src src
;
1151 src
.File
= TGSI_FILE_NULL
;
1157 src
.IndirectFile
= TGSI_FILE_NULL
;
1158 src
.IndirectIndex
= 0;
1159 src
.IndirectSwizzle
= 0;
1164 src
.DimensionIndex
= 0;
1165 src
.DimIndirect
= 0;
1166 src
.DimIndFile
= TGSI_FILE_NULL
;
1167 src
.DimIndIndex
= 0;
1168 src
.DimIndSwizzle
= 0;
1174 static inline boolean
1175 ureg_src_is_undef( struct ureg_src src
)
1177 return src
.File
== TGSI_FILE_NULL
;
1180 static inline boolean
1181 ureg_dst_is_undef( struct ureg_dst dst
)
1183 return dst
.File
== TGSI_FILE_NULL
;