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(unsigned processor
);
99 ureg_create_with_screen(unsigned processor
, struct pipe_screen
*screen
);
101 const struct tgsi_token
*
102 ureg_finalize( struct ureg_program
* );
104 /* Create and return a shader:
107 ureg_create_shader( struct ureg_program
*,
108 struct pipe_context
*pipe
,
109 const struct pipe_stream_output_info
*so
);
112 ureg_set_next_shader_processor(struct ureg_program
*ureg
, unsigned processor
);
114 /* Alternately, return the built token stream and hand ownership of
115 * that memory to the caller:
117 const struct tgsi_token
*
118 ureg_get_tokens( struct ureg_program
*ureg
,
119 unsigned *nr_tokens
);
122 * Returns the number of currently declared outputs.
125 ureg_get_nr_outputs( const struct ureg_program
*ureg
);
128 /* Free the tokens created by ureg_get_tokens() */
129 void ureg_free_tokens( const struct tgsi_token
*tokens
);
133 ureg_destroy( struct ureg_program
* );
136 /***********************************************************************
137 * Convenience routine:
140 ureg_create_shader_with_so_and_destroy( struct ureg_program
*p
,
141 struct pipe_context
*pipe
,
142 const struct pipe_stream_output_info
*so
)
144 void *result
= ureg_create_shader( p
, pipe
, so
);
150 ureg_create_shader_and_destroy( struct ureg_program
*p
,
151 struct pipe_context
*pipe
)
153 return ureg_create_shader_with_so_and_destroy(p
, pipe
, NULL
);
157 /***********************************************************************
158 * Build shader properties:
162 ureg_property(struct ureg_program
*ureg
, unsigned name
, unsigned value
);
165 /***********************************************************************
166 * Build shader declarations:
170 ureg_DECL_fs_input_cyl_centroid_layout(struct ureg_program
*,
171 unsigned semantic_name
,
172 unsigned semantic_index
,
173 unsigned interp_mode
,
174 unsigned cylindrical_wrap
,
175 unsigned interp_location
,
179 unsigned array_size
);
182 ureg_DECL_fs_input_cyl_centroid(struct ureg_program
*,
183 unsigned semantic_name
,
184 unsigned semantic_index
,
185 unsigned interp_mode
,
186 unsigned cylindrical_wrap
,
187 unsigned interp_location
,
189 unsigned array_size
);
191 static inline struct ureg_src
192 ureg_DECL_fs_input_cyl(struct ureg_program
*ureg
,
193 unsigned semantic_name
,
194 unsigned semantic_index
,
195 unsigned interp_mode
,
196 unsigned cylindrical_wrap
)
198 return ureg_DECL_fs_input_cyl_centroid(ureg
,
206 static inline struct ureg_src
207 ureg_DECL_fs_input(struct ureg_program
*ureg
,
208 unsigned semantic_name
,
209 unsigned semantic_index
,
210 unsigned interp_mode
)
212 return ureg_DECL_fs_input_cyl_centroid(ureg
,
220 ureg_DECL_vs_input( struct ureg_program
*,
224 ureg_DECL_input_layout(struct ureg_program
*,
225 unsigned semantic_name
,
226 unsigned semantic_index
,
230 unsigned array_size
);
233 ureg_DECL_input(struct ureg_program
*,
234 unsigned semantic_name
,
235 unsigned semantic_index
,
237 unsigned array_size
);
240 ureg_DECL_system_value(struct ureg_program
*,
241 unsigned semantic_name
,
242 unsigned semantic_index
);
245 ureg_DECL_output_layout(struct ureg_program
*,
246 unsigned semantic_name
,
247 unsigned semantic_index
,
252 unsigned array_size
);
255 ureg_DECL_output_masked(struct ureg_program
*,
256 unsigned semantic_name
,
257 unsigned semantic_index
,
260 unsigned array_size
);
263 ureg_DECL_output(struct ureg_program
*,
264 unsigned semantic_name
,
265 unsigned semantic_index
);
268 ureg_DECL_output_array(struct ureg_program
*ureg
,
269 unsigned semantic_name
,
270 unsigned semantic_index
,
272 unsigned array_size
);
275 ureg_DECL_immediate( struct ureg_program
*,
280 ureg_DECL_immediate_f64( struct ureg_program
*,
285 ureg_DECL_immediate_uint( struct ureg_program
*,
290 ureg_DECL_immediate_block_uint( struct ureg_program
*,
295 ureg_DECL_immediate_int( struct ureg_program
*,
300 ureg_DECL_immediate_uint64( struct ureg_program
*,
305 ureg_DECL_immediate_int64( struct ureg_program
*,
310 ureg_DECL_constant2D(struct ureg_program
*ureg
,
316 ureg_DECL_constant( struct ureg_program
*,
320 ureg_DECL_temporary( struct ureg_program
* );
323 * Emit a temporary with the LOCAL declaration flag set. For use when
324 * the register value is not required to be preserved across
325 * subroutine boundaries.
328 ureg_DECL_local_temporary( struct ureg_program
* );
331 * Declare "size" continuous temporary registers.
334 ureg_DECL_array_temporary( struct ureg_program
*,
339 ureg_release_temporary( struct ureg_program
*ureg
,
340 struct ureg_dst tmp
);
343 ureg_DECL_address( struct ureg_program
* );
345 /* Supply an index to the sampler declaration as this is the hook to
346 * the external pipe_sampler state. Users of this function probably
347 * don't want just any sampler, but a specific one which they've set
348 * up state for in the context.
351 ureg_DECL_sampler( struct ureg_program
*,
355 ureg_DECL_sampler_view(struct ureg_program
*,
358 unsigned return_type_x
,
359 unsigned return_type_y
,
360 unsigned return_type_z
,
361 unsigned return_type_w
);
364 ureg_DECL_image(struct ureg_program
*ureg
,
372 ureg_DECL_buffer(struct ureg_program
*ureg
, unsigned nr
, bool atomic
);
375 ureg_DECL_memory(struct ureg_program
*ureg
, unsigned memory_type
);
377 static inline struct ureg_src
378 ureg_imm4f( struct ureg_program
*ureg
,
387 return ureg_DECL_immediate( ureg
, v
, 4 );
390 static inline struct ureg_src
391 ureg_imm3f( struct ureg_program
*ureg
,
399 return ureg_DECL_immediate( ureg
, v
, 3 );
402 static inline struct ureg_src
403 ureg_imm2f( struct ureg_program
*ureg
,
409 return ureg_DECL_immediate( ureg
, v
, 2 );
412 static inline struct ureg_src
413 ureg_imm1f( struct ureg_program
*ureg
,
418 return ureg_DECL_immediate( ureg
, v
, 1 );
421 static inline struct ureg_src
422 ureg_imm4u( struct ureg_program
*ureg
,
423 unsigned a
, unsigned b
,
424 unsigned c
, unsigned d
)
431 return ureg_DECL_immediate_uint( ureg
, v
, 4 );
434 static inline struct ureg_src
435 ureg_imm3u( struct ureg_program
*ureg
,
436 unsigned a
, unsigned b
,
443 return ureg_DECL_immediate_uint( ureg
, v
, 3 );
446 static inline struct ureg_src
447 ureg_imm2u( struct ureg_program
*ureg
,
448 unsigned a
, unsigned b
)
453 return ureg_DECL_immediate_uint( ureg
, v
, 2 );
456 static inline struct ureg_src
457 ureg_imm1u( struct ureg_program
*ureg
,
460 return ureg_DECL_immediate_uint( ureg
, &a
, 1 );
463 static inline struct ureg_src
464 ureg_imm4i( struct ureg_program
*ureg
,
473 return ureg_DECL_immediate_int( ureg
, v
, 4 );
476 static inline struct ureg_src
477 ureg_imm3i( struct ureg_program
*ureg
,
485 return ureg_DECL_immediate_int( ureg
, v
, 3 );
488 static inline struct ureg_src
489 ureg_imm2i( struct ureg_program
*ureg
,
495 return ureg_DECL_immediate_int( ureg
, v
, 2 );
498 static inline struct ureg_src
499 ureg_imm1i( struct ureg_program
*ureg
,
502 return ureg_DECL_immediate_int( ureg
, &a
, 1 );
505 /* Where the destination register has a valid file, but an empty
508 static inline boolean
509 ureg_dst_is_empty( struct ureg_dst dst
)
511 return dst
.File
!= TGSI_FILE_NULL
&&
515 /***********************************************************************
516 * Functions for patching up labels
520 /* Will return a number which can be used in a label to point to the
521 * next instruction to be emitted.
524 ureg_get_instruction_number( struct ureg_program
*ureg
);
527 /* Patch a given label (expressed as a token number) to point to a
528 * given instruction (expressed as an instruction number).
530 * Labels are obtained from instruction emitters, eg ureg_CAL().
531 * Instruction numbers are obtained from ureg_get_instruction_number(),
535 ureg_fixup_label(struct ureg_program
*ureg
,
536 unsigned label_token
,
537 unsigned instruction_number
);
540 /* Generic instruction emitter. Use if you need to pass the opcode as
541 * a parameter, rather than using the emit_OP() variants below.
544 ureg_insn(struct ureg_program
*ureg
,
546 const struct ureg_dst
*dst
,
548 const struct ureg_src
*src
,
553 ureg_tex_insn(struct ureg_program
*ureg
,
555 const struct ureg_dst
*dst
,
558 unsigned return_type
,
559 const struct tgsi_texture_offset
*texoffsets
,
561 const struct ureg_src
*src
,
566 ureg_memory_insn(struct ureg_program
*ureg
,
568 const struct ureg_dst
*dst
,
570 const struct ureg_src
*src
,
576 /***********************************************************************
577 * Internal instruction helpers, don't call these directly:
580 struct ureg_emit_insn_result
{
581 unsigned insn_token
; /*< Used to fixup insn size. */
582 unsigned extended_token
; /*< Used to set the Extended bit, usually the same as insn_token. */
585 struct ureg_emit_insn_result
586 ureg_emit_insn(struct ureg_program
*ureg
,
593 ureg_emit_label(struct ureg_program
*ureg
,
595 unsigned *label_token
);
598 ureg_emit_texture(struct ureg_program
*ureg
,
600 unsigned target
, unsigned return_type
, unsigned num_offsets
);
603 ureg_emit_texture_offset(struct ureg_program
*ureg
,
604 const struct tgsi_texture_offset
*offset
);
607 ureg_emit_memory(struct ureg_program
*ureg
,
614 ureg_emit_dst( struct ureg_program
*ureg
,
615 struct ureg_dst dst
);
618 ureg_emit_src( struct ureg_program
*ureg
,
619 struct ureg_src src
);
622 ureg_fixup_insn_size(struct ureg_program
*ureg
,
627 static inline void ureg_##op( struct ureg_program *ureg ) \
629 unsigned opcode = TGSI_OPCODE_##op; \
630 struct ureg_emit_insn_result insn; \
631 insn = ureg_emit_insn(ureg, \
636 ureg_fixup_insn_size( ureg, insn.insn_token ); \
640 static inline void ureg_##op( struct ureg_program *ureg, \
641 struct ureg_src src ) \
643 unsigned opcode = TGSI_OPCODE_##op; \
644 struct ureg_emit_insn_result insn; \
645 insn = ureg_emit_insn(ureg, \
650 ureg_emit_src( ureg, src ); \
651 ureg_fixup_insn_size( ureg, insn.insn_token ); \
654 #define OP00_LBL( op ) \
655 static inline void ureg_##op( struct ureg_program *ureg, \
656 unsigned *label_token ) \
658 unsigned opcode = TGSI_OPCODE_##op; \
659 struct ureg_emit_insn_result insn; \
660 insn = ureg_emit_insn(ureg, \
665 ureg_emit_label( ureg, insn.extended_token, label_token ); \
666 ureg_fixup_insn_size( ureg, insn.insn_token ); \
669 #define OP01_LBL( op ) \
670 static inline void ureg_##op( struct ureg_program *ureg, \
671 struct ureg_src src, \
672 unsigned *label_token ) \
674 unsigned opcode = TGSI_OPCODE_##op; \
675 struct ureg_emit_insn_result insn; \
676 insn = ureg_emit_insn(ureg, \
681 ureg_emit_label( ureg, insn.extended_token, label_token ); \
682 ureg_emit_src( ureg, src ); \
683 ureg_fixup_insn_size( ureg, insn.insn_token ); \
687 static inline void ureg_##op( struct ureg_program *ureg, \
688 struct ureg_dst dst ) \
690 unsigned opcode = TGSI_OPCODE_##op; \
691 struct ureg_emit_insn_result insn; \
692 if (ureg_dst_is_empty(dst)) \
694 insn = ureg_emit_insn(ureg, \
699 ureg_emit_dst( ureg, dst ); \
700 ureg_fixup_insn_size( ureg, insn.insn_token ); \
705 static inline void ureg_##op( struct ureg_program *ureg, \
706 struct ureg_dst dst, \
707 struct ureg_src src ) \
709 unsigned opcode = TGSI_OPCODE_##op; \
710 struct ureg_emit_insn_result insn; \
711 if (ureg_dst_is_empty(dst)) \
713 insn = ureg_emit_insn(ureg, \
718 ureg_emit_dst( ureg, dst ); \
719 ureg_emit_src( ureg, src ); \
720 ureg_fixup_insn_size( ureg, insn.insn_token ); \
724 static inline void ureg_##op( struct ureg_program *ureg, \
725 struct ureg_dst dst, \
726 struct ureg_src src0, \
727 struct ureg_src src1 ) \
729 unsigned opcode = TGSI_OPCODE_##op; \
730 struct ureg_emit_insn_result insn; \
731 if (ureg_dst_is_empty(dst)) \
733 insn = ureg_emit_insn(ureg, \
738 ureg_emit_dst( ureg, dst ); \
739 ureg_emit_src( ureg, src0 ); \
740 ureg_emit_src( ureg, src1 ); \
741 ureg_fixup_insn_size( ureg, insn.insn_token ); \
744 #define OP12_TEX( op ) \
745 static inline void ureg_##op( struct ureg_program *ureg, \
746 struct ureg_dst dst, \
748 struct ureg_src src0, \
749 struct ureg_src src1 ) \
751 unsigned opcode = TGSI_OPCODE_##op; \
752 unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \
753 struct ureg_emit_insn_result insn; \
754 if (ureg_dst_is_empty(dst)) \
756 insn = ureg_emit_insn(ureg, \
761 ureg_emit_texture( ureg, insn.extended_token, target, \
763 ureg_emit_dst( ureg, dst ); \
764 ureg_emit_src( ureg, src0 ); \
765 ureg_emit_src( ureg, src1 ); \
766 ureg_fixup_insn_size( ureg, insn.insn_token ); \
770 static inline void ureg_##op( struct ureg_program *ureg, \
771 struct ureg_dst dst, \
772 struct ureg_src src0, \
773 struct ureg_src src1, \
774 struct ureg_src src2 ) \
776 unsigned opcode = TGSI_OPCODE_##op; \
777 struct ureg_emit_insn_result insn; \
778 if (ureg_dst_is_empty(dst)) \
780 insn = ureg_emit_insn(ureg, \
785 ureg_emit_dst( ureg, dst ); \
786 ureg_emit_src( ureg, src0 ); \
787 ureg_emit_src( ureg, src1 ); \
788 ureg_emit_src( ureg, src2 ); \
789 ureg_fixup_insn_size( ureg, insn.insn_token ); \
792 #define OP14_TEX( op ) \
793 static inline void ureg_##op( struct ureg_program *ureg, \
794 struct ureg_dst dst, \
796 struct ureg_src src0, \
797 struct ureg_src src1, \
798 struct ureg_src src2, \
799 struct ureg_src src3 ) \
801 unsigned opcode = TGSI_OPCODE_##op; \
802 unsigned return_type = TGSI_RETURN_TYPE_UNKNOWN; \
803 struct ureg_emit_insn_result insn; \
804 if (ureg_dst_is_empty(dst)) \
806 insn = ureg_emit_insn(ureg, \
811 ureg_emit_texture( ureg, insn.extended_token, target, \
813 ureg_emit_dst( ureg, dst ); \
814 ureg_emit_src( ureg, src0 ); \
815 ureg_emit_src( ureg, src1 ); \
816 ureg_emit_src( ureg, src2 ); \
817 ureg_emit_src( ureg, src3 ); \
818 ureg_fixup_insn_size( ureg, insn.insn_token ); \
821 /* Use a template include to generate a correctly-typed ureg_OP()
822 * function for each TGSI opcode:
824 #include "tgsi_opcode_tmp.h"
827 /***********************************************************************
828 * Inline helpers for manipulating register structs:
830 static inline struct ureg_src
831 ureg_negate( struct ureg_src reg
)
833 assert(reg
.File
!= TGSI_FILE_NULL
);
838 static inline struct ureg_src
839 ureg_abs( struct ureg_src reg
)
841 assert(reg
.File
!= TGSI_FILE_NULL
);
847 static inline struct ureg_src
848 ureg_swizzle( struct ureg_src reg
,
849 int x
, int y
, int z
, int w
)
851 unsigned swz
= ( (reg
.SwizzleX
<< 0) |
852 (reg
.SwizzleY
<< 2) |
853 (reg
.SwizzleZ
<< 4) |
854 (reg
.SwizzleW
<< 6));
856 assert(reg
.File
!= TGSI_FILE_NULL
);
862 reg
.SwizzleX
= (swz
>> (x
*2)) & 0x3;
863 reg
.SwizzleY
= (swz
>> (y
*2)) & 0x3;
864 reg
.SwizzleZ
= (swz
>> (z
*2)) & 0x3;
865 reg
.SwizzleW
= (swz
>> (w
*2)) & 0x3;
869 static inline struct ureg_src
870 ureg_scalar( struct ureg_src reg
, int x
)
872 return ureg_swizzle(reg
, x
, x
, x
, x
);
875 static inline struct ureg_dst
876 ureg_writemask( struct ureg_dst reg
,
879 assert(reg
.File
!= TGSI_FILE_NULL
);
880 reg
.WriteMask
&= writemask
;
884 static inline struct ureg_dst
885 ureg_saturate( struct ureg_dst reg
)
887 assert(reg
.File
!= TGSI_FILE_NULL
);
892 static inline struct ureg_dst
893 ureg_dst_indirect( struct ureg_dst reg
, struct ureg_src addr
)
895 assert(reg
.File
!= TGSI_FILE_NULL
);
896 assert(addr
.File
== TGSI_FILE_ADDRESS
|| addr
.File
== TGSI_FILE_TEMPORARY
);
898 reg
.IndirectFile
= addr
.File
;
899 reg
.IndirectIndex
= addr
.Index
;
900 reg
.IndirectSwizzle
= addr
.SwizzleX
;
904 static inline struct ureg_src
905 ureg_src_indirect( struct ureg_src reg
, struct ureg_src addr
)
907 assert(reg
.File
!= TGSI_FILE_NULL
);
908 assert(addr
.File
== TGSI_FILE_ADDRESS
|| addr
.File
== TGSI_FILE_TEMPORARY
);
910 reg
.IndirectFile
= addr
.File
;
911 reg
.IndirectIndex
= addr
.Index
;
912 reg
.IndirectSwizzle
= addr
.SwizzleX
;
916 static inline struct ureg_dst
917 ureg_dst_dimension( struct ureg_dst reg
, int index
)
919 assert(reg
.File
!= TGSI_FILE_NULL
);
922 reg
.DimensionIndex
= index
;
926 static inline struct ureg_src
927 ureg_src_dimension( struct ureg_src reg
, int index
)
929 assert(reg
.File
!= TGSI_FILE_NULL
);
932 reg
.DimensionIndex
= index
;
936 static inline struct ureg_dst
937 ureg_dst_dimension_indirect( struct ureg_dst reg
, struct ureg_src addr
,
940 assert(reg
.File
!= TGSI_FILE_NULL
);
943 reg
.DimensionIndex
= index
;
944 reg
.DimIndFile
= addr
.File
;
945 reg
.DimIndIndex
= addr
.Index
;
946 reg
.DimIndSwizzle
= addr
.SwizzleX
;
950 static inline struct ureg_src
951 ureg_src_dimension_indirect( struct ureg_src reg
, struct ureg_src addr
,
954 assert(reg
.File
!= TGSI_FILE_NULL
);
957 reg
.DimensionIndex
= index
;
958 reg
.DimIndFile
= addr
.File
;
959 reg
.DimIndIndex
= addr
.Index
;
960 reg
.DimIndSwizzle
= addr
.SwizzleX
;
964 static inline struct ureg_src
965 ureg_src_array_offset(struct ureg_src reg
, int offset
)
971 static inline struct ureg_dst
972 ureg_dst_array_offset( struct ureg_dst reg
, int offset
)
978 static inline struct ureg_dst
979 ureg_dst_array_register(unsigned file
,
986 dst
.WriteMask
= TGSI_WRITEMASK_XYZW
;
988 dst
.IndirectFile
= TGSI_FILE_NULL
;
989 dst
.IndirectIndex
= 0;
990 dst
.IndirectSwizzle
= 0;
994 dst
.DimensionIndex
= 0;
996 dst
.DimIndFile
= TGSI_FILE_NULL
;
998 dst
.DimIndSwizzle
= 0;
999 dst
.ArrayID
= array_id
;
1004 static inline struct ureg_dst
1005 ureg_dst_register(unsigned file
,
1008 return ureg_dst_array_register(file
, index
, 0);
1011 static inline struct ureg_dst
1012 ureg_dst( struct ureg_src src
)
1014 struct ureg_dst dst
;
1016 assert(!src
.Indirect
||
1017 (src
.IndirectFile
== TGSI_FILE_ADDRESS
||
1018 src
.IndirectFile
== TGSI_FILE_TEMPORARY
));
1020 dst
.File
= src
.File
;
1021 dst
.WriteMask
= TGSI_WRITEMASK_XYZW
;
1022 dst
.IndirectFile
= src
.IndirectFile
;
1023 dst
.Indirect
= src
.Indirect
;
1024 dst
.IndirectIndex
= src
.IndirectIndex
;
1025 dst
.IndirectSwizzle
= src
.IndirectSwizzle
;
1027 dst
.Index
= src
.Index
;
1028 dst
.Dimension
= src
.Dimension
;
1029 dst
.DimensionIndex
= src
.DimensionIndex
;
1030 dst
.DimIndirect
= src
.DimIndirect
;
1031 dst
.DimIndFile
= src
.DimIndFile
;
1032 dst
.DimIndIndex
= src
.DimIndIndex
;
1033 dst
.DimIndSwizzle
= src
.DimIndSwizzle
;
1034 dst
.ArrayID
= src
.ArrayID
;
1039 static inline struct ureg_src
1040 ureg_src_array_register(unsigned file
,
1044 struct ureg_src src
;
1047 src
.SwizzleX
= TGSI_SWIZZLE_X
;
1048 src
.SwizzleY
= TGSI_SWIZZLE_Y
;
1049 src
.SwizzleZ
= TGSI_SWIZZLE_Z
;
1050 src
.SwizzleW
= TGSI_SWIZZLE_W
;
1052 src
.IndirectFile
= TGSI_FILE_NULL
;
1053 src
.IndirectIndex
= 0;
1054 src
.IndirectSwizzle
= 0;
1059 src
.DimensionIndex
= 0;
1060 src
.DimIndirect
= 0;
1061 src
.DimIndFile
= TGSI_FILE_NULL
;
1062 src
.DimIndIndex
= 0;
1063 src
.DimIndSwizzle
= 0;
1064 src
.ArrayID
= array_id
;
1069 static inline struct ureg_src
1070 ureg_src_register(unsigned file
,
1073 return ureg_src_array_register(file
, index
, 0);
1076 static inline struct ureg_src
1077 ureg_src( struct ureg_dst dst
)
1079 struct ureg_src src
;
1081 src
.File
= dst
.File
;
1082 src
.SwizzleX
= TGSI_SWIZZLE_X
;
1083 src
.SwizzleY
= TGSI_SWIZZLE_Y
;
1084 src
.SwizzleZ
= TGSI_SWIZZLE_Z
;
1085 src
.SwizzleW
= TGSI_SWIZZLE_W
;
1086 src
.Indirect
= dst
.Indirect
;
1087 src
.IndirectFile
= dst
.IndirectFile
;
1088 src
.IndirectIndex
= dst
.IndirectIndex
;
1089 src
.IndirectSwizzle
= dst
.IndirectSwizzle
;
1091 src
.Index
= dst
.Index
;
1093 src
.Dimension
= dst
.Dimension
;
1094 src
.DimensionIndex
= dst
.DimensionIndex
;
1095 src
.DimIndirect
= dst
.DimIndirect
;
1096 src
.DimIndFile
= dst
.DimIndFile
;
1097 src
.DimIndIndex
= dst
.DimIndIndex
;
1098 src
.DimIndSwizzle
= dst
.DimIndSwizzle
;
1099 src
.ArrayID
= dst
.ArrayID
;
1106 static inline struct ureg_dst
1107 ureg_dst_undef( void )
1109 struct ureg_dst dst
;
1111 dst
.File
= TGSI_FILE_NULL
;
1114 dst
.IndirectFile
= TGSI_FILE_NULL
;
1115 dst
.IndirectIndex
= 0;
1116 dst
.IndirectSwizzle
= 0;
1120 dst
.DimensionIndex
= 0;
1121 dst
.DimIndirect
= 0;
1122 dst
.DimIndFile
= TGSI_FILE_NULL
;
1123 dst
.DimIndIndex
= 0;
1124 dst
.DimIndSwizzle
= 0;
1130 static inline struct ureg_src
1131 ureg_src_undef( void )
1133 struct ureg_src src
;
1135 src
.File
= TGSI_FILE_NULL
;
1141 src
.IndirectFile
= TGSI_FILE_NULL
;
1142 src
.IndirectIndex
= 0;
1143 src
.IndirectSwizzle
= 0;
1148 src
.DimensionIndex
= 0;
1149 src
.DimIndirect
= 0;
1150 src
.DimIndFile
= TGSI_FILE_NULL
;
1151 src
.DimIndIndex
= 0;
1152 src
.DimIndSwizzle
= 0;
1158 static inline boolean
1159 ureg_src_is_undef( struct ureg_src src
)
1161 return src
.File
== TGSI_FILE_NULL
;
1164 static inline boolean
1165 ureg_dst_is_undef( struct ureg_dst dst
)
1167 return dst
.File
== TGSI_FILE_NULL
;