2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a 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, sublicense, 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
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
37 #include "brw_structs.h"
38 #include "brw_defines.h"
39 #include "program/prog_instruction.h"
45 #define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
46 #define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
48 #define BRW_SWIZZLE_NOOP BRW_SWIZZLE4(0,1,2,3)
49 #define BRW_SWIZZLE_XYZW BRW_SWIZZLE4(0,1,2,3)
50 #define BRW_SWIZZLE_XXXX BRW_SWIZZLE4(0,0,0,0)
51 #define BRW_SWIZZLE_YYYY BRW_SWIZZLE4(1,1,1,1)
52 #define BRW_SWIZZLE_ZZZZ BRW_SWIZZLE4(2,2,2,2)
53 #define BRW_SWIZZLE_WWWW BRW_SWIZZLE4(3,3,3,3)
54 #define BRW_SWIZZLE_XYXY BRW_SWIZZLE4(0,1,0,1)
56 static inline bool brw_is_single_value_swizzle(int swiz
)
58 return (swiz
== BRW_SWIZZLE_XXXX
||
59 swiz
== BRW_SWIZZLE_YYYY
||
60 swiz
== BRW_SWIZZLE_ZZZZ
||
61 swiz
== BRW_SWIZZLE_WWWW
);
64 #define REG_SIZE (8*4)
67 /* These aren't hardware structs, just something useful for us to pass around:
69 * Align1 operation has a lot of control over input ranges. Used in
70 * WM programs to implement shaders decomposed into "channel serial"
71 * or "structure of array" form:
78 GLuint subnr
:5; /* :1 in align16 */
79 GLuint negate
:1; /* source only */
80 GLuint abs
:1; /* source only */
81 GLuint vstride
:4; /* source only */
82 GLuint width
:3; /* src only, align1 only */
83 GLuint hstride
:2; /* align1 only */
84 GLuint address_mode
:1; /* relative addressing, hopefully! */
89 GLuint swizzle
:8; /* src only, align16 only */
90 GLuint writemask
:4; /* dest only, align16 only */
91 GLint indirect_offset
:10; /* relative addressing offset */
92 GLuint pad1
:10; /* two dwords total */
102 struct brw_indirect
{
104 GLint addr_offset
:10;
109 #define BRW_EU_MAX_INSN_STACK 5
112 struct brw_instruction
*store
;
115 unsigned int next_insn_offset
;
119 /* Allow clients to push/pop instruction state:
121 struct brw_instruction stack
[BRW_EU_MAX_INSN_STACK
];
122 bool compressed_stack
[BRW_EU_MAX_INSN_STACK
];
123 struct brw_instruction
*current
;
126 bool single_program_flow
;
128 struct brw_context
*brw
;
130 /* Control flow stacks:
131 * - if_stack contains IF and ELSE instructions which must be patched
132 * (and popped) once the matching ENDIF instruction is encountered.
134 * Just store the instruction pointer(an index).
138 int if_stack_array_size
;
141 * loop_stack contains the instruction pointers of the starts of loops which
142 * must be patched (and popped) once the matching WHILE instruction is
147 * pre-gen6, the BREAK and CONT instructions had to tell how many IF/ENDIF
148 * blocks they were popping out of, to fix up the mask stack. This tracks
149 * the IF/ENDIF nesting in each current nested loop level.
151 int *if_depth_in_loop
;
152 int loop_stack_depth
;
153 int loop_stack_array_size
;
156 static INLINE
int type_sz( GLuint type
)
159 case BRW_REGISTER_TYPE_UD
:
160 case BRW_REGISTER_TYPE_D
:
161 case BRW_REGISTER_TYPE_F
:
163 case BRW_REGISTER_TYPE_HF
:
164 case BRW_REGISTER_TYPE_UW
:
165 case BRW_REGISTER_TYPE_W
:
167 case BRW_REGISTER_TYPE_UB
:
168 case BRW_REGISTER_TYPE_B
:
176 * Construct a brw_reg.
177 * \param file one of the BRW_x_REGISTER_FILE values
178 * \param nr register number/index
179 * \param subnr register sub number
180 * \param type one of BRW_REGISTER_TYPE_x
181 * \param vstride one of BRW_VERTICAL_STRIDE_x
182 * \param width one of BRW_WIDTH_x
183 * \param hstride one of BRW_HORIZONTAL_STRIDE_x
184 * \param swizzle one of BRW_SWIZZLE_x
185 * \param writemask WRITEMASK_X/Y/Z/W bitfield
187 static INLINE
struct brw_reg
brw_reg( GLuint file
,
198 if (file
== BRW_GENERAL_REGISTER_FILE
)
199 assert(nr
< BRW_MAX_GRF
);
200 else if (file
== BRW_MESSAGE_REGISTER_FILE
)
201 assert((nr
& ~(1 << 7)) < BRW_MAX_MRF
);
202 else if (file
== BRW_ARCHITECTURE_REGISTER_FILE
)
203 assert(nr
<= BRW_ARF_TIMESTAMP
);
208 reg
.subnr
= subnr
* type_sz(type
);
211 reg
.vstride
= vstride
;
213 reg
.hstride
= hstride
;
214 reg
.address_mode
= BRW_ADDRESS_DIRECT
;
217 /* Could do better: If the reg is r5.3<0;1,0>, we probably want to
218 * set swizzle and writemask to W, as the lower bits of subnr will
219 * be lost when converted to align16. This is probably too much to
220 * keep track of as you'd want it adjusted by suboffset(), etc.
221 * Perhaps fix up when converting to align16?
223 reg
.dw1
.bits
.swizzle
= swizzle
;
224 reg
.dw1
.bits
.writemask
= writemask
;
225 reg
.dw1
.bits
.indirect_offset
= 0;
226 reg
.dw1
.bits
.pad1
= 0;
230 /** Construct float[16] register */
231 static INLINE
struct brw_reg
brw_vec16_reg( GLuint file
,
239 BRW_VERTICAL_STRIDE_16
,
241 BRW_HORIZONTAL_STRIDE_1
,
246 /** Construct float[8] register */
247 static INLINE
struct brw_reg
brw_vec8_reg( GLuint file
,
255 BRW_VERTICAL_STRIDE_8
,
257 BRW_HORIZONTAL_STRIDE_1
,
262 /** Construct float[4] register */
263 static INLINE
struct brw_reg
brw_vec4_reg( GLuint file
,
271 BRW_VERTICAL_STRIDE_4
,
273 BRW_HORIZONTAL_STRIDE_1
,
278 /** Construct float[2] register */
279 static INLINE
struct brw_reg
brw_vec2_reg( GLuint file
,
287 BRW_VERTICAL_STRIDE_2
,
289 BRW_HORIZONTAL_STRIDE_1
,
294 /** Construct float[1] register */
295 static INLINE
struct brw_reg
brw_vec1_reg( GLuint file
,
303 BRW_VERTICAL_STRIDE_0
,
305 BRW_HORIZONTAL_STRIDE_0
,
311 static INLINE
struct brw_reg
retype( struct brw_reg reg
,
318 static inline struct brw_reg
319 sechalf(struct brw_reg reg
)
326 static INLINE
struct brw_reg
suboffset( struct brw_reg reg
,
329 reg
.subnr
+= delta
* type_sz(reg
.type
);
334 static INLINE
struct brw_reg
offset( struct brw_reg reg
,
342 static INLINE
struct brw_reg
byte_offset( struct brw_reg reg
,
345 GLuint newoffset
= reg
.nr
* REG_SIZE
+ reg
.subnr
+ bytes
;
346 reg
.nr
= newoffset
/ REG_SIZE
;
347 reg
.subnr
= newoffset
% REG_SIZE
;
352 /** Construct unsigned word[16] register */
353 static INLINE
struct brw_reg
brw_uw16_reg( GLuint file
,
357 return suboffset(retype(brw_vec16_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
360 /** Construct unsigned word[8] register */
361 static INLINE
struct brw_reg
brw_uw8_reg( GLuint file
,
365 return suboffset(retype(brw_vec8_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
368 /** Construct unsigned word[1] register */
369 static INLINE
struct brw_reg
brw_uw1_reg( GLuint file
,
373 return suboffset(retype(brw_vec1_reg(file
, nr
, 0), BRW_REGISTER_TYPE_UW
), subnr
);
376 static INLINE
struct brw_reg
brw_imm_reg( GLuint type
)
378 return brw_reg( BRW_IMMEDIATE_VALUE
,
382 BRW_VERTICAL_STRIDE_0
,
384 BRW_HORIZONTAL_STRIDE_0
,
389 /** Construct float immediate register */
390 static INLINE
struct brw_reg
brw_imm_f( GLfloat f
)
392 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_F
);
397 /** Construct integer immediate register */
398 static INLINE
struct brw_reg
brw_imm_d( GLint d
)
400 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_D
);
405 /** Construct uint immediate register */
406 static INLINE
struct brw_reg
brw_imm_ud( GLuint ud
)
408 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_UD
);
413 /** Construct ushort immediate register */
414 static INLINE
struct brw_reg
brw_imm_uw( GLushort uw
)
416 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_UW
);
417 imm
.dw1
.ud
= uw
| (uw
<< 16);
421 /** Construct short immediate register */
422 static INLINE
struct brw_reg
brw_imm_w( GLshort w
)
424 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_W
);
425 imm
.dw1
.d
= w
| (w
<< 16);
429 /* brw_imm_b and brw_imm_ub aren't supported by hardware - the type
430 * numbers alias with _V and _VF below:
433 /** Construct vector of eight signed half-byte values */
434 static INLINE
struct brw_reg
brw_imm_v( GLuint v
)
436 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_V
);
437 imm
.vstride
= BRW_VERTICAL_STRIDE_0
;
438 imm
.width
= BRW_WIDTH_8
;
439 imm
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
444 /** Construct vector of four 8-bit float values */
445 static INLINE
struct brw_reg
brw_imm_vf( GLuint v
)
447 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_VF
);
448 imm
.vstride
= BRW_VERTICAL_STRIDE_0
;
449 imm
.width
= BRW_WIDTH_4
;
450 imm
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
457 #define VF_NEG (1<<7)
459 static INLINE
struct brw_reg
brw_imm_vf4( GLuint v0
,
464 struct brw_reg imm
= brw_imm_reg(BRW_REGISTER_TYPE_VF
);
465 imm
.vstride
= BRW_VERTICAL_STRIDE_0
;
466 imm
.width
= BRW_WIDTH_4
;
467 imm
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
468 imm
.dw1
.ud
= ((v0
<< 0) |
476 static INLINE
struct brw_reg
brw_address( struct brw_reg reg
)
478 return brw_imm_uw(reg
.nr
* REG_SIZE
+ reg
.subnr
);
481 /** Construct float[1] general-purpose register */
482 static INLINE
struct brw_reg
brw_vec1_grf( GLuint nr
, GLuint subnr
)
484 return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
487 /** Construct float[2] general-purpose register */
488 static INLINE
struct brw_reg
brw_vec2_grf( GLuint nr
, GLuint subnr
)
490 return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
493 /** Construct float[4] general-purpose register */
494 static INLINE
struct brw_reg
brw_vec4_grf( GLuint nr
, GLuint subnr
)
496 return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
499 /** Construct float[8] general-purpose register */
500 static INLINE
struct brw_reg
brw_vec8_grf( GLuint nr
, GLuint subnr
)
502 return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
506 static INLINE
struct brw_reg
brw_uw8_grf( GLuint nr
, GLuint subnr
)
508 return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
511 static INLINE
struct brw_reg
brw_uw16_grf( GLuint nr
, GLuint subnr
)
513 return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE
, nr
, subnr
);
517 /** Construct null register (usually used for setting condition codes) */
518 static INLINE
struct brw_reg
brw_null_reg( void )
520 return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
525 static INLINE
struct brw_reg
brw_address_reg( GLuint subnr
)
527 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
532 /* If/else instructions break in align16 mode if writemask & swizzle
533 * aren't xyzw. This goes against the convention for other scalar
536 static INLINE
struct brw_reg
brw_ip_reg( void )
538 return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
541 BRW_REGISTER_TYPE_UD
,
542 BRW_VERTICAL_STRIDE_4
, /* ? */
544 BRW_HORIZONTAL_STRIDE_0
,
545 BRW_SWIZZLE_XYZW
, /* NOTE! */
546 WRITEMASK_XYZW
); /* NOTE! */
549 static INLINE
struct brw_reg
brw_acc_reg( void )
551 return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
556 static INLINE
struct brw_reg
brw_notification_1_reg(void)
559 return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
560 BRW_ARF_NOTIFICATION_COUNT
,
562 BRW_REGISTER_TYPE_UD
,
563 BRW_VERTICAL_STRIDE_0
,
565 BRW_HORIZONTAL_STRIDE_0
,
571 static INLINE
struct brw_reg
brw_flag_reg(int reg
, int subreg
)
573 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
579 static INLINE
struct brw_reg
brw_mask_reg( GLuint subnr
)
581 return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE
,
586 static INLINE
struct brw_reg
brw_message_reg( GLuint nr
)
588 assert((nr
& ~(1 << 7)) < BRW_MAX_MRF
);
589 return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE
,
597 /* This is almost always called with a numeric constant argument, so
598 * make things easy to evaluate at compile time:
600 static INLINE GLuint
cvt( GLuint val
)
614 static INLINE
struct brw_reg
stride( struct brw_reg reg
,
619 reg
.vstride
= cvt(vstride
);
620 reg
.width
= cvt(width
) - 1;
621 reg
.hstride
= cvt(hstride
);
626 static INLINE
struct brw_reg
vec16( struct brw_reg reg
)
628 return stride(reg
, 16,16,1);
631 static INLINE
struct brw_reg
vec8( struct brw_reg reg
)
633 return stride(reg
, 8,8,1);
636 static INLINE
struct brw_reg
vec4( struct brw_reg reg
)
638 return stride(reg
, 4,4,1);
641 static INLINE
struct brw_reg
vec2( struct brw_reg reg
)
643 return stride(reg
, 2,2,1);
646 static INLINE
struct brw_reg
vec1( struct brw_reg reg
)
648 return stride(reg
, 0,1,0);
652 static INLINE
struct brw_reg
get_element( struct brw_reg reg
, GLuint elt
)
654 return vec1(suboffset(reg
, elt
));
657 static INLINE
struct brw_reg
get_element_ud( struct brw_reg reg
, GLuint elt
)
659 return vec1(suboffset(retype(reg
, BRW_REGISTER_TYPE_UD
), elt
));
662 static INLINE
struct brw_reg
get_element_d( struct brw_reg reg
, GLuint elt
)
664 return vec1(suboffset(retype(reg
, BRW_REGISTER_TYPE_D
), elt
));
668 static INLINE
struct brw_reg
brw_swizzle( struct brw_reg reg
,
674 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
676 reg
.dw1
.bits
.swizzle
= BRW_SWIZZLE4(BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, x
),
677 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, y
),
678 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, z
),
679 BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, w
));
684 static INLINE
struct brw_reg
brw_swizzle1( struct brw_reg reg
,
687 return brw_swizzle(reg
, x
, x
, x
, x
);
690 static INLINE
struct brw_reg
brw_writemask( struct brw_reg reg
,
693 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
694 reg
.dw1
.bits
.writemask
&= mask
;
698 static INLINE
struct brw_reg
brw_set_writemask( struct brw_reg reg
,
701 assert(reg
.file
!= BRW_IMMEDIATE_VALUE
);
702 reg
.dw1
.bits
.writemask
= mask
;
706 static INLINE
struct brw_reg
negate( struct brw_reg reg
)
712 static INLINE
struct brw_reg
brw_abs( struct brw_reg reg
)
719 /***********************************************************************
721 static INLINE
struct brw_reg
brw_vec4_indirect( GLuint subnr
,
724 struct brw_reg reg
= brw_vec4_grf(0, 0);
726 reg
.address_mode
= BRW_ADDRESS_REGISTER_INDIRECT_REGISTER
;
727 reg
.dw1
.bits
.indirect_offset
= offset
;
731 static INLINE
struct brw_reg
brw_vec1_indirect( GLuint subnr
,
734 struct brw_reg reg
= brw_vec1_grf(0, 0);
736 reg
.address_mode
= BRW_ADDRESS_REGISTER_INDIRECT_REGISTER
;
737 reg
.dw1
.bits
.indirect_offset
= offset
;
741 static INLINE
struct brw_reg
deref_4f(struct brw_indirect ptr
, GLint offset
)
743 return brw_vec4_indirect(ptr
.addr_subnr
, ptr
.addr_offset
+ offset
);
746 static INLINE
struct brw_reg
deref_1f(struct brw_indirect ptr
, GLint offset
)
748 return brw_vec1_indirect(ptr
.addr_subnr
, ptr
.addr_offset
+ offset
);
751 static INLINE
struct brw_reg
deref_4b(struct brw_indirect ptr
, GLint offset
)
753 return retype(deref_4f(ptr
, offset
), BRW_REGISTER_TYPE_B
);
756 static INLINE
struct brw_reg
deref_1uw(struct brw_indirect ptr
, GLint offset
)
758 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_UW
);
761 static INLINE
struct brw_reg
deref_1d(struct brw_indirect ptr
, GLint offset
)
763 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_D
);
766 static INLINE
struct brw_reg
deref_1ud(struct brw_indirect ptr
, GLint offset
)
768 return retype(deref_1f(ptr
, offset
), BRW_REGISTER_TYPE_UD
);
771 static INLINE
struct brw_reg
get_addr_reg(struct brw_indirect ptr
)
773 return brw_address_reg(ptr
.addr_subnr
);
776 static INLINE
struct brw_indirect
brw_indirect_offset( struct brw_indirect ptr
, GLint offset
)
778 ptr
.addr_offset
+= offset
;
782 static INLINE
struct brw_indirect
brw_indirect( GLuint addr_subnr
, GLint offset
)
784 struct brw_indirect ptr
;
785 ptr
.addr_subnr
= addr_subnr
;
786 ptr
.addr_offset
= offset
;
791 /** Do two brw_regs refer to the same register? */
793 brw_same_reg(struct brw_reg r1
, struct brw_reg r2
)
795 return r1
.file
== r2
.file
&& r1
.nr
== r2
.nr
;
798 static INLINE
struct brw_instruction
*current_insn( struct brw_compile
*p
)
800 return &p
->store
[p
->nr_insn
];
803 void brw_pop_insn_state( struct brw_compile
*p
);
804 void brw_push_insn_state( struct brw_compile
*p
);
805 void brw_set_mask_control( struct brw_compile
*p
, GLuint value
);
806 void brw_set_saturate( struct brw_compile
*p
, bool enable
);
807 void brw_set_access_mode( struct brw_compile
*p
, GLuint access_mode
);
808 void brw_set_compression_control(struct brw_compile
*p
, enum brw_compression c
);
809 void brw_set_predicate_control_flag_value( struct brw_compile
*p
, GLuint value
);
810 void brw_set_predicate_control( struct brw_compile
*p
, GLuint pc
);
811 void brw_set_predicate_inverse(struct brw_compile
*p
, bool predicate_inverse
);
812 void brw_set_conditionalmod( struct brw_compile
*p
, GLuint conditional
);
813 void brw_set_acc_write_control(struct brw_compile
*p
, GLuint value
);
815 void brw_init_compile(struct brw_context
*, struct brw_compile
*p
,
817 void brw_dump_compile(struct brw_compile
*p
, FILE *out
, int start
, int end
);
818 const GLuint
*brw_get_program( struct brw_compile
*p
, GLuint
*sz
);
820 struct brw_instruction
*brw_next_insn(struct brw_compile
*p
, GLuint opcode
);
821 void brw_set_dest(struct brw_compile
*p
, struct brw_instruction
*insn
,
822 struct brw_reg dest
);
823 void brw_set_src0(struct brw_compile
*p
, struct brw_instruction
*insn
,
826 void gen6_resolve_implied_move(struct brw_compile
*p
,
830 /* Helpers for regular instructions:
833 struct brw_instruction *brw_##OP(struct brw_compile *p, \
834 struct brw_reg dest, \
835 struct brw_reg src0);
838 struct brw_instruction *brw_##OP(struct brw_compile *p, \
839 struct brw_reg dest, \
840 struct brw_reg src0, \
841 struct brw_reg src1);
844 struct brw_instruction *brw_##OP(struct brw_compile *p, \
845 struct brw_reg dest, \
846 struct brw_reg src0, \
847 struct brw_reg src1, \
848 struct brw_reg src2);
851 void brw_##OP(struct brw_compile *p, struct brw_reg dest, struct brw_reg src0);
890 /* Helpers for SEND instruction:
892 void brw_set_sampler_message(struct brw_compile
*p
,
893 struct brw_instruction
*insn
,
894 GLuint binding_table_index
,
897 GLuint response_length
,
899 GLuint header_present
,
901 GLuint return_format
);
903 void brw_set_dp_read_message(struct brw_compile
*p
,
904 struct brw_instruction
*insn
,
905 GLuint binding_table_index
,
911 GLuint response_length
);
913 void brw_set_dp_write_message(struct brw_compile
*p
,
914 struct brw_instruction
*insn
,
915 GLuint binding_table_index
,
920 GLuint last_render_target
,
921 GLuint response_length
,
922 GLuint end_of_thread
,
923 GLuint send_commit_msg
);
925 void brw_urb_WRITE(struct brw_compile
*p
,
932 GLuint response_length
,
934 bool writes_complete
,
938 void brw_ff_sync(struct brw_compile
*p
,
943 GLuint response_length
,
946 void brw_svb_write(struct brw_compile
*p
,
950 GLuint binding_table_index
,
951 bool send_commit_msg
);
953 void brw_fb_WRITE(struct brw_compile
*p
,
958 GLuint binding_table_index
,
960 GLuint response_length
,
962 bool header_present
);
964 void brw_SAMPLE(struct brw_compile
*p
,
968 GLuint binding_table_index
,
972 GLuint response_length
,
974 GLuint header_present
,
976 GLuint return_format
);
978 void brw_math( struct brw_compile
*p
,
986 void brw_math2(struct brw_compile
*p
,
990 struct brw_reg src1
);
992 void brw_oword_block_read(struct brw_compile
*p
,
996 uint32_t bind_table_index
);
998 void brw_oword_block_read_scratch(struct brw_compile
*p
,
1004 void brw_oword_block_write_scratch(struct brw_compile
*p
,
1009 void brw_shader_time_add(struct brw_compile
*p
,
1011 uint32_t surf_index
);
1013 /* If/else/endif. Works by manipulating the execution flags on each
1016 struct brw_instruction
*brw_IF(struct brw_compile
*p
,
1017 GLuint execute_size
);
1018 struct brw_instruction
*gen6_IF(struct brw_compile
*p
, uint32_t conditional
,
1019 struct brw_reg src0
, struct brw_reg src1
);
1021 void brw_ELSE(struct brw_compile
*p
);
1022 void brw_ENDIF(struct brw_compile
*p
);
1026 struct brw_instruction
*brw_DO(struct brw_compile
*p
,
1027 GLuint execute_size
);
1029 struct brw_instruction
*brw_WHILE(struct brw_compile
*p
);
1031 struct brw_instruction
*brw_BREAK(struct brw_compile
*p
);
1032 struct brw_instruction
*brw_CONT(struct brw_compile
*p
);
1033 struct brw_instruction
*gen6_CONT(struct brw_compile
*p
);
1036 void brw_land_fwd_jump(struct brw_compile
*p
, int jmp_insn_idx
);
1040 void brw_NOP(struct brw_compile
*p
);
1042 void brw_WAIT(struct brw_compile
*p
);
1044 /* Special case: there is never a destination, execution size will be
1047 void brw_CMP(struct brw_compile
*p
,
1048 struct brw_reg dest
,
1050 struct brw_reg src0
,
1051 struct brw_reg src1
);
1053 void brw_print_reg( struct brw_reg reg
);
1056 /***********************************************************************
1060 void brw_copy_indirect_to_indirect(struct brw_compile
*p
,
1061 struct brw_indirect dst_ptr
,
1062 struct brw_indirect src_ptr
,
1065 void brw_copy_from_indirect(struct brw_compile
*p
,
1067 struct brw_indirect ptr
,
1070 void brw_copy4(struct brw_compile
*p
,
1075 void brw_copy8(struct brw_compile
*p
,
1080 void brw_math_invert( struct brw_compile
*p
,
1082 struct brw_reg src
);
1084 void brw_set_src1(struct brw_compile
*p
,
1085 struct brw_instruction
*insn
,
1086 struct brw_reg reg
);
1088 void brw_set_uip_jip(struct brw_compile
*p
);
1090 uint32_t brw_swap_cmod(uint32_t cmod
);
1092 /* brw_eu_compact.c */
1093 void brw_init_compaction_tables(struct intel_context
*intel
);
1094 void brw_compact_instructions(struct brw_compile
*p
);
1095 void brw_uncompact_instruction(struct intel_context
*intel
,
1096 struct brw_instruction
*dst
,
1097 struct brw_compact_instruction
*src
);
1098 bool brw_try_compact_instruction(struct brw_compile
*p
,
1099 struct brw_compact_instruction
*dst
,
1100 struct brw_instruction
*src
);
1102 void brw_debug_compact_uncompact(struct intel_context
*intel
,
1103 struct brw_instruction
*orig
,
1104 struct brw_instruction
*uncompacted
);
1106 /* brw_optimize.c */
1107 void brw_optimize(struct brw_compile
*p
);
1108 void brw_remove_duplicate_mrf_moves(struct brw_compile
*p
);
1109 void brw_remove_grf_to_mrf_moves(struct brw_compile
*p
);