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>
33 #include "brw_context.h"
34 #include "brw_defines.h"
40 /***********************************************************************
41 * Internal helper for constructing instructions
44 static void guess_execution_size( struct brw_instruction
*insn
,
47 if (reg
.width
== BRW_WIDTH_8
&&
48 insn
->header
.compression_control
== BRW_COMPRESSION_COMPRESSED
)
49 insn
->header
.execution_size
= BRW_EXECUTE_16
;
51 insn
->header
.execution_size
= reg
.width
; /* note - definitions are compatible */
55 static void brw_set_dest( struct brw_instruction
*insn
,
58 if (dest
.type
!= BRW_ARCHITECTURE_REGISTER_FILE
)
59 assert(dest
.nr
< 128);
61 insn
->bits1
.da1
.dest_reg_file
= dest
.file
;
62 insn
->bits1
.da1
.dest_reg_type
= dest
.type
;
63 insn
->bits1
.da1
.dest_address_mode
= dest
.address_mode
;
65 if (dest
.address_mode
== BRW_ADDRESS_DIRECT
) {
66 insn
->bits1
.da1
.dest_reg_nr
= dest
.nr
;
68 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
69 insn
->bits1
.da1
.dest_subreg_nr
= dest
.subnr
;
70 if (dest
.hstride
== BRW_HORIZONTAL_STRIDE_0
)
71 dest
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
72 insn
->bits1
.da1
.dest_horiz_stride
= dest
.hstride
;
75 insn
->bits1
.da16
.dest_subreg_nr
= dest
.subnr
/ 16;
76 insn
->bits1
.da16
.dest_writemask
= dest
.dw1
.bits
.writemask
;
80 insn
->bits1
.ia1
.dest_subreg_nr
= dest
.subnr
;
82 /* These are different sizes in align1 vs align16:
84 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
85 insn
->bits1
.ia1
.dest_indirect_offset
= dest
.dw1
.bits
.indirect_offset
;
86 if (dest
.hstride
== BRW_HORIZONTAL_STRIDE_0
)
87 dest
.hstride
= BRW_HORIZONTAL_STRIDE_1
;
88 insn
->bits1
.ia1
.dest_horiz_stride
= dest
.hstride
;
91 insn
->bits1
.ia16
.dest_indirect_offset
= dest
.dw1
.bits
.indirect_offset
;
95 /* NEW: Set the execution size based on dest.width and
96 * insn->compression_control:
98 guess_execution_size(insn
, dest
);
101 static void brw_set_src0( struct brw_instruction
*insn
,
104 assert(reg
.file
!= BRW_MESSAGE_REGISTER_FILE
);
106 if (reg
.type
!= BRW_ARCHITECTURE_REGISTER_FILE
)
107 assert(reg
.nr
< 128);
109 insn
->bits1
.da1
.src0_reg_file
= reg
.file
;
110 insn
->bits1
.da1
.src0_reg_type
= reg
.type
;
111 insn
->bits2
.da1
.src0_abs
= reg
.abs
;
112 insn
->bits2
.da1
.src0_negate
= reg
.negate
;
113 insn
->bits2
.da1
.src0_address_mode
= reg
.address_mode
;
115 if (reg
.file
== BRW_IMMEDIATE_VALUE
) {
116 insn
->bits3
.ud
= reg
.dw1
.ud
;
118 /* Required to set some fields in src1 as well:
120 insn
->bits1
.da1
.src1_reg_file
= 0; /* arf */
121 insn
->bits1
.da1
.src1_reg_type
= reg
.type
;
125 if (reg
.address_mode
== BRW_ADDRESS_DIRECT
) {
126 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
127 insn
->bits2
.da1
.src0_subreg_nr
= reg
.subnr
;
128 insn
->bits2
.da1
.src0_reg_nr
= reg
.nr
;
131 insn
->bits2
.da16
.src0_subreg_nr
= reg
.subnr
/ 16;
132 insn
->bits2
.da16
.src0_reg_nr
= reg
.nr
;
136 insn
->bits2
.ia1
.src0_subreg_nr
= reg
.subnr
;
138 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
139 insn
->bits2
.ia1
.src0_indirect_offset
= reg
.dw1
.bits
.indirect_offset
;
142 insn
->bits2
.ia16
.src0_subreg_nr
= reg
.dw1
.bits
.indirect_offset
;
146 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
147 if (reg
.width
== BRW_WIDTH_1
&&
148 insn
->header
.execution_size
== BRW_EXECUTE_1
) {
149 insn
->bits2
.da1
.src0_horiz_stride
= BRW_HORIZONTAL_STRIDE_0
;
150 insn
->bits2
.da1
.src0_width
= BRW_WIDTH_1
;
151 insn
->bits2
.da1
.src0_vert_stride
= BRW_VERTICAL_STRIDE_0
;
154 insn
->bits2
.da1
.src0_horiz_stride
= reg
.hstride
;
155 insn
->bits2
.da1
.src0_width
= reg
.width
;
156 insn
->bits2
.da1
.src0_vert_stride
= reg
.vstride
;
160 insn
->bits2
.da16
.src0_swz_x
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_X
);
161 insn
->bits2
.da16
.src0_swz_y
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_Y
);
162 insn
->bits2
.da16
.src0_swz_z
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_Z
);
163 insn
->bits2
.da16
.src0_swz_w
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_W
);
165 /* This is an oddity of the fact we're using the same
166 * descriptions for registers in align_16 as align_1:
168 if (reg
.vstride
== BRW_VERTICAL_STRIDE_8
)
169 insn
->bits2
.da16
.src0_vert_stride
= BRW_VERTICAL_STRIDE_4
;
171 insn
->bits2
.da16
.src0_vert_stride
= reg
.vstride
;
177 void brw_set_src1( struct brw_instruction
*insn
,
180 assert(reg
.file
!= BRW_MESSAGE_REGISTER_FILE
);
182 assert(reg
.nr
< 128);
184 insn
->bits1
.da1
.src1_reg_file
= reg
.file
;
185 insn
->bits1
.da1
.src1_reg_type
= reg
.type
;
186 insn
->bits3
.da1
.src1_abs
= reg
.abs
;
187 insn
->bits3
.da1
.src1_negate
= reg
.negate
;
189 /* Only src1 can be immediate in two-argument instructions.
191 assert(insn
->bits1
.da1
.src0_reg_file
!= BRW_IMMEDIATE_VALUE
);
193 if (reg
.file
== BRW_IMMEDIATE_VALUE
) {
194 insn
->bits3
.ud
= reg
.dw1
.ud
;
197 /* This is a hardware restriction, which may or may not be lifted
200 assert (reg
.address_mode
== BRW_ADDRESS_DIRECT
);
201 //assert (reg.file == BRW_GENERAL_REGISTER_FILE);
203 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
204 insn
->bits3
.da1
.src1_subreg_nr
= reg
.subnr
;
205 insn
->bits3
.da1
.src1_reg_nr
= reg
.nr
;
208 insn
->bits3
.da16
.src1_subreg_nr
= reg
.subnr
/ 16;
209 insn
->bits3
.da16
.src1_reg_nr
= reg
.nr
;
212 if (insn
->header
.access_mode
== BRW_ALIGN_1
) {
213 if (reg
.width
== BRW_WIDTH_1
&&
214 insn
->header
.execution_size
== BRW_EXECUTE_1
) {
215 insn
->bits3
.da1
.src1_horiz_stride
= BRW_HORIZONTAL_STRIDE_0
;
216 insn
->bits3
.da1
.src1_width
= BRW_WIDTH_1
;
217 insn
->bits3
.da1
.src1_vert_stride
= BRW_VERTICAL_STRIDE_0
;
220 insn
->bits3
.da1
.src1_horiz_stride
= reg
.hstride
;
221 insn
->bits3
.da1
.src1_width
= reg
.width
;
222 insn
->bits3
.da1
.src1_vert_stride
= reg
.vstride
;
226 insn
->bits3
.da16
.src1_swz_x
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_X
);
227 insn
->bits3
.da16
.src1_swz_y
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_Y
);
228 insn
->bits3
.da16
.src1_swz_z
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_Z
);
229 insn
->bits3
.da16
.src1_swz_w
= BRW_GET_SWZ(reg
.dw1
.bits
.swizzle
, BRW_CHANNEL_W
);
231 /* This is an oddity of the fact we're using the same
232 * descriptions for registers in align_16 as align_1:
234 if (reg
.vstride
== BRW_VERTICAL_STRIDE_8
)
235 insn
->bits3
.da16
.src1_vert_stride
= BRW_VERTICAL_STRIDE_4
;
237 insn
->bits3
.da16
.src1_vert_stride
= reg
.vstride
;
244 static void brw_set_math_message( struct brw_context
*brw
,
245 struct brw_instruction
*insn
,
247 GLuint response_length
,
250 GLboolean low_precision
,
254 brw_set_src1(insn
, brw_imm_d(0));
256 if (BRW_IS_IGDNG(brw
)) {
257 insn
->bits3
.math_igdng
.function
= function
;
258 insn
->bits3
.math_igdng
.int_type
= integer_type
;
259 insn
->bits3
.math_igdng
.precision
= low_precision
;
260 insn
->bits3
.math_igdng
.saturate
= saturate
;
261 insn
->bits3
.math_igdng
.data_type
= dataType
;
262 insn
->bits3
.math_igdng
.snapshot
= 0;
263 insn
->bits3
.math_igdng
.header_present
= 0;
264 insn
->bits3
.math_igdng
.response_length
= response_length
;
265 insn
->bits3
.math_igdng
.msg_length
= msg_length
;
266 insn
->bits3
.math_igdng
.end_of_thread
= 0;
267 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_MATH
;
268 insn
->bits2
.send_igdng
.end_of_thread
= 0;
270 insn
->bits3
.math
.function
= function
;
271 insn
->bits3
.math
.int_type
= integer_type
;
272 insn
->bits3
.math
.precision
= low_precision
;
273 insn
->bits3
.math
.saturate
= saturate
;
274 insn
->bits3
.math
.data_type
= dataType
;
275 insn
->bits3
.math
.response_length
= response_length
;
276 insn
->bits3
.math
.msg_length
= msg_length
;
277 insn
->bits3
.math
.msg_target
= BRW_MESSAGE_TARGET_MATH
;
278 insn
->bits3
.math
.end_of_thread
= 0;
283 static void brw_set_ff_sync_message( struct brw_context
*brw
,
284 struct brw_instruction
*insn
,
288 GLuint response_length
,
289 GLboolean end_of_thread
,
292 GLuint swizzle_control
)
294 brw_set_src1(insn
, brw_imm_d(0));
296 insn
->bits3
.urb_igdng
.opcode
= 1;
297 insn
->bits3
.urb_igdng
.offset
= offset
;
298 insn
->bits3
.urb_igdng
.swizzle_control
= swizzle_control
;
299 insn
->bits3
.urb_igdng
.allocate
= allocate
;
300 insn
->bits3
.urb_igdng
.used
= used
;
301 insn
->bits3
.urb_igdng
.complete
= complete
;
302 insn
->bits3
.urb_igdng
.header_present
= 1;
303 insn
->bits3
.urb_igdng
.response_length
= response_length
;
304 insn
->bits3
.urb_igdng
.msg_length
= msg_length
;
305 insn
->bits3
.urb_igdng
.end_of_thread
= end_of_thread
;
306 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_URB
;
307 insn
->bits2
.send_igdng
.end_of_thread
= end_of_thread
;
310 static void brw_set_urb_message( struct brw_context
*brw
,
311 struct brw_instruction
*insn
,
315 GLuint response_length
,
316 GLboolean end_of_thread
,
319 GLuint swizzle_control
)
321 brw_set_src1(insn
, brw_imm_d(0));
323 if (BRW_IS_IGDNG(brw
)) {
324 insn
->bits3
.urb_igdng
.opcode
= 0; /* ? */
325 insn
->bits3
.urb_igdng
.offset
= offset
;
326 insn
->bits3
.urb_igdng
.swizzle_control
= swizzle_control
;
327 insn
->bits3
.urb_igdng
.allocate
= allocate
;
328 insn
->bits3
.urb_igdng
.used
= used
; /* ? */
329 insn
->bits3
.urb_igdng
.complete
= complete
;
330 insn
->bits3
.urb_igdng
.header_present
= 1;
331 insn
->bits3
.urb_igdng
.response_length
= response_length
;
332 insn
->bits3
.urb_igdng
.msg_length
= msg_length
;
333 insn
->bits3
.urb_igdng
.end_of_thread
= end_of_thread
;
334 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_URB
;
335 insn
->bits2
.send_igdng
.end_of_thread
= end_of_thread
;
337 insn
->bits3
.urb
.opcode
= 0; /* ? */
338 insn
->bits3
.urb
.offset
= offset
;
339 insn
->bits3
.urb
.swizzle_control
= swizzle_control
;
340 insn
->bits3
.urb
.allocate
= allocate
;
341 insn
->bits3
.urb
.used
= used
; /* ? */
342 insn
->bits3
.urb
.complete
= complete
;
343 insn
->bits3
.urb
.response_length
= response_length
;
344 insn
->bits3
.urb
.msg_length
= msg_length
;
345 insn
->bits3
.urb
.msg_target
= BRW_MESSAGE_TARGET_URB
;
346 insn
->bits3
.urb
.end_of_thread
= end_of_thread
;
350 static void brw_set_dp_write_message( struct brw_context
*brw
,
351 struct brw_instruction
*insn
,
352 GLuint binding_table_index
,
356 GLuint pixel_scoreboard_clear
,
357 GLuint response_length
,
358 GLuint end_of_thread
)
360 brw_set_src1(insn
, brw_imm_d(0));
362 if (BRW_IS_IGDNG(brw
)) {
363 insn
->bits3
.dp_write_igdng
.binding_table_index
= binding_table_index
;
364 insn
->bits3
.dp_write_igdng
.msg_control
= msg_control
;
365 insn
->bits3
.dp_write_igdng
.pixel_scoreboard_clear
= pixel_scoreboard_clear
;
366 insn
->bits3
.dp_write_igdng
.msg_type
= msg_type
;
367 insn
->bits3
.dp_write_igdng
.send_commit_msg
= 0;
368 insn
->bits3
.dp_write_igdng
.header_present
= 1;
369 insn
->bits3
.dp_write_igdng
.response_length
= response_length
;
370 insn
->bits3
.dp_write_igdng
.msg_length
= msg_length
;
371 insn
->bits3
.dp_write_igdng
.end_of_thread
= end_of_thread
;
372 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_DATAPORT_WRITE
;
373 insn
->bits2
.send_igdng
.end_of_thread
= end_of_thread
;
375 insn
->bits3
.dp_write
.binding_table_index
= binding_table_index
;
376 insn
->bits3
.dp_write
.msg_control
= msg_control
;
377 insn
->bits3
.dp_write
.pixel_scoreboard_clear
= pixel_scoreboard_clear
;
378 insn
->bits3
.dp_write
.msg_type
= msg_type
;
379 insn
->bits3
.dp_write
.send_commit_msg
= 0;
380 insn
->bits3
.dp_write
.response_length
= response_length
;
381 insn
->bits3
.dp_write
.msg_length
= msg_length
;
382 insn
->bits3
.dp_write
.msg_target
= BRW_MESSAGE_TARGET_DATAPORT_WRITE
;
383 insn
->bits3
.dp_write
.end_of_thread
= end_of_thread
;
387 static void brw_set_dp_read_message( struct brw_context
*brw
,
388 struct brw_instruction
*insn
,
389 GLuint binding_table_index
,
394 GLuint response_length
,
395 GLuint end_of_thread
)
397 brw_set_src1(insn
, brw_imm_d(0));
399 if (BRW_IS_IGDNG(brw
)) {
400 insn
->bits3
.dp_read_igdng
.binding_table_index
= binding_table_index
;
401 insn
->bits3
.dp_read_igdng
.msg_control
= msg_control
;
402 insn
->bits3
.dp_read_igdng
.msg_type
= msg_type
;
403 insn
->bits3
.dp_read_igdng
.target_cache
= target_cache
;
404 insn
->bits3
.dp_read_igdng
.header_present
= 1;
405 insn
->bits3
.dp_read_igdng
.response_length
= response_length
;
406 insn
->bits3
.dp_read_igdng
.msg_length
= msg_length
;
407 insn
->bits3
.dp_read_igdng
.pad1
= 0;
408 insn
->bits3
.dp_read_igdng
.end_of_thread
= end_of_thread
;
409 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_DATAPORT_READ
;
410 insn
->bits2
.send_igdng
.end_of_thread
= end_of_thread
;
412 insn
->bits3
.dp_read
.binding_table_index
= binding_table_index
; /*0:7*/
413 insn
->bits3
.dp_read
.msg_control
= msg_control
; /*8:11*/
414 insn
->bits3
.dp_read
.msg_type
= msg_type
; /*12:13*/
415 insn
->bits3
.dp_read
.target_cache
= target_cache
; /*14:15*/
416 insn
->bits3
.dp_read
.response_length
= response_length
; /*16:19*/
417 insn
->bits3
.dp_read
.msg_length
= msg_length
; /*20:23*/
418 insn
->bits3
.dp_read
.msg_target
= BRW_MESSAGE_TARGET_DATAPORT_READ
; /*24:27*/
419 insn
->bits3
.dp_read
.pad1
= 0; /*28:30*/
420 insn
->bits3
.dp_read
.end_of_thread
= end_of_thread
; /*31*/
424 static void brw_set_sampler_message(struct brw_context
*brw
,
425 struct brw_instruction
*insn
,
426 GLuint binding_table_index
,
429 GLuint response_length
,
432 GLuint header_present
,
436 brw_set_src1(insn
, brw_imm_d(0));
438 if (BRW_IS_IGDNG(brw
)) {
439 insn
->bits3
.sampler_igdng
.binding_table_index
= binding_table_index
;
440 insn
->bits3
.sampler_igdng
.sampler
= sampler
;
441 insn
->bits3
.sampler_igdng
.msg_type
= msg_type
;
442 insn
->bits3
.sampler_igdng
.simd_mode
= simd_mode
;
443 insn
->bits3
.sampler_igdng
.header_present
= header_present
;
444 insn
->bits3
.sampler_igdng
.response_length
= response_length
;
445 insn
->bits3
.sampler_igdng
.msg_length
= msg_length
;
446 insn
->bits3
.sampler_igdng
.end_of_thread
= eot
;
447 insn
->bits2
.send_igdng
.sfid
= BRW_MESSAGE_TARGET_SAMPLER
;
448 insn
->bits2
.send_igdng
.end_of_thread
= eot
;
449 } else if (BRW_IS_G4X(brw
)) {
450 insn
->bits3
.sampler_g4x
.binding_table_index
= binding_table_index
;
451 insn
->bits3
.sampler_g4x
.sampler
= sampler
;
452 insn
->bits3
.sampler_g4x
.msg_type
= msg_type
;
453 insn
->bits3
.sampler_g4x
.response_length
= response_length
;
454 insn
->bits3
.sampler_g4x
.msg_length
= msg_length
;
455 insn
->bits3
.sampler_g4x
.end_of_thread
= eot
;
456 insn
->bits3
.sampler_g4x
.msg_target
= BRW_MESSAGE_TARGET_SAMPLER
;
458 insn
->bits3
.sampler
.binding_table_index
= binding_table_index
;
459 insn
->bits3
.sampler
.sampler
= sampler
;
460 insn
->bits3
.sampler
.msg_type
= msg_type
;
461 insn
->bits3
.sampler
.return_format
= BRW_SAMPLER_RETURN_FORMAT_FLOAT32
;
462 insn
->bits3
.sampler
.response_length
= response_length
;
463 insn
->bits3
.sampler
.msg_length
= msg_length
;
464 insn
->bits3
.sampler
.end_of_thread
= eot
;
465 insn
->bits3
.sampler
.msg_target
= BRW_MESSAGE_TARGET_SAMPLER
;
471 static struct brw_instruction
*next_insn( struct brw_compile
*p
,
474 struct brw_instruction
*insn
;
476 assert(p
->nr_insn
+ 1 < BRW_EU_MAX_INSN
);
478 insn
= &p
->store
[p
->nr_insn
++];
479 memcpy(insn
, p
->current
, sizeof(*insn
));
481 /* Reset this one-shot flag:
484 if (p
->current
->header
.destreg__conditonalmod
) {
485 p
->current
->header
.destreg__conditonalmod
= 0;
486 p
->current
->header
.predicate_control
= BRW_PREDICATE_NORMAL
;
489 insn
->header
.opcode
= opcode
;
494 static struct brw_instruction
*brw_alu1( struct brw_compile
*p
,
499 struct brw_instruction
*insn
= next_insn(p
, opcode
);
500 brw_set_dest(insn
, dest
);
501 brw_set_src0(insn
, src
);
505 static struct brw_instruction
*brw_alu2(struct brw_compile
*p
,
509 struct brw_reg src1
)
511 struct brw_instruction
*insn
= next_insn(p
, opcode
);
512 brw_set_dest(insn
, dest
);
513 brw_set_src0(insn
, src0
);
514 brw_set_src1(insn
, src1
);
519 /***********************************************************************
520 * Convenience routines.
523 struct brw_instruction *brw_##OP(struct brw_compile *p, \
524 struct brw_reg dest, \
525 struct brw_reg src0) \
527 return brw_alu1(p, BRW_OPCODE_##OP, dest, src0); \
531 struct brw_instruction *brw_##OP(struct brw_compile *p, \
532 struct brw_reg dest, \
533 struct brw_reg src0, \
534 struct brw_reg src1) \
536 return brw_alu2(p, BRW_OPCODE_##OP, dest, src0, src1); \
568 void brw_NOP(struct brw_compile
*p
)
570 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_NOP
);
571 brw_set_dest(insn
, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD
));
572 brw_set_src0(insn
, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD
));
573 brw_set_src1(insn
, brw_imm_ud(0x0));
580 /***********************************************************************
581 * Comparisons, if/else/endif
584 struct brw_instruction
*brw_JMPI(struct brw_compile
*p
,
589 struct brw_instruction
*insn
= brw_alu2(p
, BRW_OPCODE_JMPI
, dest
, src0
, src1
);
591 insn
->header
.execution_size
= 1;
592 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
593 insn
->header
.mask_control
= BRW_MASK_DISABLE
;
595 p
->current
->header
.predicate_control
= BRW_PREDICATE_NONE
;
600 /* EU takes the value from the flag register and pushes it onto some
601 * sort of a stack (presumably merging with any flag value already on
602 * the stack). Within an if block, the flags at the top of the stack
603 * control execution on each channel of the unit, eg. on each of the
604 * 16 pixel values in our wm programs.
606 * When the matching 'else' instruction is reached (presumably by
607 * countdown of the instruction count patched in by our ELSE/ENDIF
608 * functions), the relevent flags are inverted.
610 * When the matching 'endif' instruction is reached, the flags are
611 * popped off. If the stack is now empty, normal execution resumes.
613 * No attempt is made to deal with stack overflow (14 elements?).
615 struct brw_instruction
*brw_IF(struct brw_compile
*p
, GLuint execute_size
)
617 struct brw_instruction
*insn
;
619 if (p
->single_program_flow
) {
620 assert(execute_size
== BRW_EXECUTE_1
);
622 insn
= next_insn(p
, BRW_OPCODE_ADD
);
623 insn
->header
.predicate_inverse
= 1;
625 insn
= next_insn(p
, BRW_OPCODE_IF
);
628 /* Override the defaults for this instruction:
630 brw_set_dest(insn
, brw_ip_reg());
631 brw_set_src0(insn
, brw_ip_reg());
632 brw_set_src1(insn
, brw_imm_d(0x0));
634 insn
->header
.execution_size
= execute_size
;
635 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
636 insn
->header
.predicate_control
= BRW_PREDICATE_NORMAL
;
637 insn
->header
.mask_control
= BRW_MASK_ENABLE
;
638 if (!p
->single_program_flow
)
639 insn
->header
.thread_control
= BRW_THREAD_SWITCH
;
641 p
->current
->header
.predicate_control
= BRW_PREDICATE_NONE
;
647 struct brw_instruction
*brw_ELSE(struct brw_compile
*p
,
648 struct brw_instruction
*if_insn
)
650 struct brw_instruction
*insn
;
653 if (BRW_IS_IGDNG(p
->brw
))
656 if (p
->single_program_flow
) {
657 insn
= next_insn(p
, BRW_OPCODE_ADD
);
659 insn
= next_insn(p
, BRW_OPCODE_ELSE
);
662 brw_set_dest(insn
, brw_ip_reg());
663 brw_set_src0(insn
, brw_ip_reg());
664 brw_set_src1(insn
, brw_imm_d(0x0));
666 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
667 insn
->header
.execution_size
= if_insn
->header
.execution_size
;
668 insn
->header
.mask_control
= BRW_MASK_ENABLE
;
669 if (!p
->single_program_flow
)
670 insn
->header
.thread_control
= BRW_THREAD_SWITCH
;
672 /* Patch the if instruction to point at this instruction.
674 if (p
->single_program_flow
) {
675 assert(if_insn
->header
.opcode
== BRW_OPCODE_ADD
);
677 if_insn
->bits3
.ud
= (insn
- if_insn
+ 1) * 16;
679 assert(if_insn
->header
.opcode
== BRW_OPCODE_IF
);
681 if_insn
->bits3
.if_else
.jump_count
= br
* (insn
- if_insn
);
682 if_insn
->bits3
.if_else
.pop_count
= 1;
683 if_insn
->bits3
.if_else
.pad0
= 0;
689 void brw_ENDIF(struct brw_compile
*p
,
690 struct brw_instruction
*patch_insn
)
694 if (BRW_IS_IGDNG(p
->brw
))
697 if (p
->single_program_flow
) {
698 /* In single program flow mode, there's no need to execute an ENDIF,
699 * since we don't need to do any stack operations, and if we're executing
700 * currently, we want to just continue executing.
702 struct brw_instruction
*next
= &p
->store
[p
->nr_insn
];
704 assert(patch_insn
->header
.opcode
== BRW_OPCODE_ADD
);
706 patch_insn
->bits3
.ud
= (next
- patch_insn
) * 16;
708 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_ENDIF
);
710 brw_set_dest(insn
, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD
));
711 brw_set_src0(insn
, retype(brw_vec4_grf(0,0), BRW_REGISTER_TYPE_UD
));
712 brw_set_src1(insn
, brw_imm_d(0x0));
714 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
715 insn
->header
.execution_size
= patch_insn
->header
.execution_size
;
716 insn
->header
.mask_control
= BRW_MASK_ENABLE
;
717 insn
->header
.thread_control
= BRW_THREAD_SWITCH
;
719 assert(patch_insn
->bits3
.if_else
.jump_count
== 0);
721 /* Patch the if or else instructions to point at this or the next
722 * instruction respectively.
724 if (patch_insn
->header
.opcode
== BRW_OPCODE_IF
) {
725 /* Automagically turn it into an IFF:
727 patch_insn
->header
.opcode
= BRW_OPCODE_IFF
;
728 patch_insn
->bits3
.if_else
.jump_count
= br
* (insn
- patch_insn
+ 1);
729 patch_insn
->bits3
.if_else
.pop_count
= 0;
730 patch_insn
->bits3
.if_else
.pad0
= 0;
731 } else if (patch_insn
->header
.opcode
== BRW_OPCODE_ELSE
) {
732 patch_insn
->bits3
.if_else
.jump_count
= br
* (insn
- patch_insn
+ 1);
733 patch_insn
->bits3
.if_else
.pop_count
= 1;
734 patch_insn
->bits3
.if_else
.pad0
= 0;
739 /* Also pop item off the stack in the endif instruction:
741 insn
->bits3
.if_else
.jump_count
= 0;
742 insn
->bits3
.if_else
.pop_count
= 1;
743 insn
->bits3
.if_else
.pad0
= 0;
747 struct brw_instruction
*brw_BREAK(struct brw_compile
*p
)
749 struct brw_instruction
*insn
;
750 insn
= next_insn(p
, BRW_OPCODE_BREAK
);
751 brw_set_dest(insn
, brw_ip_reg());
752 brw_set_src0(insn
, brw_ip_reg());
753 brw_set_src1(insn
, brw_imm_d(0x0));
754 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
755 insn
->header
.execution_size
= BRW_EXECUTE_8
;
756 /* insn->header.mask_control = BRW_MASK_DISABLE; */
757 insn
->bits3
.if_else
.pad0
= 0;
761 struct brw_instruction
*brw_CONT(struct brw_compile
*p
)
763 struct brw_instruction
*insn
;
764 insn
= next_insn(p
, BRW_OPCODE_CONTINUE
);
765 brw_set_dest(insn
, brw_ip_reg());
766 brw_set_src0(insn
, brw_ip_reg());
767 brw_set_src1(insn
, brw_imm_d(0x0));
768 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
769 insn
->header
.execution_size
= BRW_EXECUTE_8
;
770 /* insn->header.mask_control = BRW_MASK_DISABLE; */
771 insn
->bits3
.if_else
.pad0
= 0;
777 struct brw_instruction
*brw_DO(struct brw_compile
*p
, GLuint execute_size
)
779 if (p
->single_program_flow
) {
780 return &p
->store
[p
->nr_insn
];
782 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_DO
);
784 /* Override the defaults for this instruction:
786 brw_set_dest(insn
, brw_null_reg());
787 brw_set_src0(insn
, brw_null_reg());
788 brw_set_src1(insn
, brw_null_reg());
790 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
791 insn
->header
.execution_size
= execute_size
;
792 insn
->header
.predicate_control
= BRW_PREDICATE_NONE
;
793 /* insn->header.mask_control = BRW_MASK_ENABLE; */
794 /* insn->header.mask_control = BRW_MASK_DISABLE; */
802 struct brw_instruction
*brw_WHILE(struct brw_compile
*p
,
803 struct brw_instruction
*do_insn
)
805 struct brw_instruction
*insn
;
808 if (BRW_IS_IGDNG(p
->brw
))
811 if (p
->single_program_flow
)
812 insn
= next_insn(p
, BRW_OPCODE_ADD
);
814 insn
= next_insn(p
, BRW_OPCODE_WHILE
);
816 brw_set_dest(insn
, brw_ip_reg());
817 brw_set_src0(insn
, brw_ip_reg());
818 brw_set_src1(insn
, brw_imm_d(0x0));
820 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
822 if (p
->single_program_flow
) {
823 insn
->header
.execution_size
= BRW_EXECUTE_1
;
825 insn
->bits3
.d
= (do_insn
- insn
) * 16;
827 insn
->header
.execution_size
= do_insn
->header
.execution_size
;
829 assert(do_insn
->header
.opcode
== BRW_OPCODE_DO
);
830 insn
->bits3
.if_else
.jump_count
= br
* (do_insn
- insn
+ 1);
831 insn
->bits3
.if_else
.pop_count
= 0;
832 insn
->bits3
.if_else
.pad0
= 0;
835 /* insn->header.mask_control = BRW_MASK_ENABLE; */
837 /* insn->header.mask_control = BRW_MASK_DISABLE; */
838 p
->current
->header
.predicate_control
= BRW_PREDICATE_NONE
;
845 void brw_land_fwd_jump(struct brw_compile
*p
,
846 struct brw_instruction
*jmp_insn
)
848 struct brw_instruction
*landing
= &p
->store
[p
->nr_insn
];
851 if (BRW_IS_IGDNG(p
->brw
))
854 assert(jmp_insn
->header
.opcode
== BRW_OPCODE_JMPI
);
855 assert(jmp_insn
->bits1
.da1
.src1_reg_file
= BRW_IMMEDIATE_VALUE
);
857 jmp_insn
->bits3
.ud
= jmpi
* ((landing
- jmp_insn
) - 1);
862 /* To integrate with the above, it makes sense that the comparison
863 * instruction should populate the flag register. It might be simpler
864 * just to use the flag reg for most WM tasks?
866 void brw_CMP(struct brw_compile
*p
,
872 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_CMP
);
874 insn
->header
.destreg__conditonalmod
= conditional
;
875 brw_set_dest(insn
, dest
);
876 brw_set_src0(insn
, src0
);
877 brw_set_src1(insn
, src1
);
879 /* guess_execution_size(insn, src0); */
882 /* Make it so that future instructions will use the computed flag
883 * value until brw_set_predicate_control_flag_value() is called
886 if (dest
.file
== BRW_ARCHITECTURE_REGISTER_FILE
&&
888 p
->current
->header
.predicate_control
= BRW_PREDICATE_NORMAL
;
889 p
->flag_value
= 0xff;
895 /***********************************************************************
896 * Helpers for the various SEND message types:
899 /** Extended math function, float[8].
901 void brw_math( struct brw_compile
*p
,
910 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
911 GLuint msg_length
= (function
== BRW_MATH_FUNCTION_POW
) ? 2 : 1;
912 GLuint response_length
= (function
== BRW_MATH_FUNCTION_SINCOS
) ? 2 : 1;
914 /* Example code doesn't set predicate_control for send
917 insn
->header
.predicate_control
= 0;
918 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
920 brw_set_dest(insn
, dest
);
921 brw_set_src0(insn
, src
);
922 brw_set_math_message(p
->brw
,
924 msg_length
, response_length
,
926 BRW_MATH_INTEGER_UNSIGNED
,
933 * Extended math function, float[16].
934 * Use 2 send instructions.
936 void brw_math_16( struct brw_compile
*p
,
944 struct brw_instruction
*insn
;
945 GLuint msg_length
= (function
== BRW_MATH_FUNCTION_POW
) ? 2 : 1;
946 GLuint response_length
= (function
== BRW_MATH_FUNCTION_SINCOS
) ? 2 : 1;
948 /* First instruction:
950 brw_push_insn_state(p
);
951 brw_set_predicate_control_flag_value(p
, 0xff);
952 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
954 insn
= next_insn(p
, BRW_OPCODE_SEND
);
955 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
957 brw_set_dest(insn
, dest
);
958 brw_set_src0(insn
, src
);
959 brw_set_math_message(p
->brw
,
961 msg_length
, response_length
,
963 BRW_MATH_INTEGER_UNSIGNED
,
966 BRW_MATH_DATA_VECTOR
);
968 /* Second instruction:
970 insn
= next_insn(p
, BRW_OPCODE_SEND
);
971 insn
->header
.compression_control
= BRW_COMPRESSION_2NDHALF
;
972 insn
->header
.destreg__conditonalmod
= msg_reg_nr
+1;
974 brw_set_dest(insn
, offset(dest
,1));
975 brw_set_src0(insn
, src
);
976 brw_set_math_message(p
->brw
,
978 msg_length
, response_length
,
980 BRW_MATH_INTEGER_UNSIGNED
,
983 BRW_MATH_DATA_VECTOR
);
985 brw_pop_insn_state(p
);
990 * Write block of 16 dwords/floats to the data port Render Cache scratch buffer.
991 * Scratch offset should be a multiple of 64.
992 * Used for register spilling.
994 void brw_dp_WRITE_16( struct brw_compile
*p
,
996 GLuint scratch_offset
)
998 GLuint msg_reg_nr
= 1;
1000 brw_push_insn_state(p
);
1001 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
1002 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1004 /* set message header global offset field (reg 0, element 2) */
1006 retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D
),
1007 brw_imm_d(scratch_offset
));
1009 brw_pop_insn_state(p
);
1013 GLuint msg_length
= 3;
1014 struct brw_reg dest
= retype(brw_null_reg(), BRW_REGISTER_TYPE_UW
);
1015 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1017 insn
->header
.predicate_control
= 0; /* XXX */
1018 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1019 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1021 brw_set_dest(insn
, dest
);
1022 brw_set_src0(insn
, src
);
1024 brw_set_dp_write_message(p
->brw
,
1026 255, /* binding table index (255=stateless) */
1027 BRW_DATAPORT_OWORD_BLOCK_4_OWORDS
, /* msg_control */
1028 BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE
, /* msg_type */
1030 0, /* pixel scoreboard */
1031 0, /* response_length */
1038 * Read block of 16 dwords/floats from the data port Render Cache scratch buffer.
1039 * Scratch offset should be a multiple of 64.
1040 * Used for register spilling.
1042 void brw_dp_READ_16( struct brw_compile
*p
,
1043 struct brw_reg dest
,
1044 GLuint scratch_offset
)
1046 GLuint msg_reg_nr
= 1;
1048 brw_push_insn_state(p
);
1049 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1050 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
1052 /* set message header global offset field (reg 0, element 2) */
1054 retype(brw_vec1_grf(0, 2), BRW_REGISTER_TYPE_D
),
1055 brw_imm_d(scratch_offset
));
1057 brw_pop_insn_state(p
);
1061 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1063 insn
->header
.predicate_control
= 0; /* XXX */
1064 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1065 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1067 brw_set_dest(insn
, dest
); /* UW? */
1068 brw_set_src0(insn
, retype(brw_vec8_grf(0, 0), BRW_REGISTER_TYPE_UW
));
1070 brw_set_dp_read_message(p
->brw
,
1072 255, /* binding table index (255=stateless) */
1073 3, /* msg_control (3 means 4 Owords) */
1074 BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ
, /* msg_type */
1075 1, /* target cache (render/scratch) */
1077 2, /* response_length */
1084 * Read a float[4] vector from the data port Data Cache (const buffer).
1085 * Location (in buffer) should be a multiple of 16.
1086 * Used for fetching shader constants.
1087 * If relAddr is true, we'll do an indirect fetch using the address register.
1089 void brw_dp_READ_4( struct brw_compile
*p
,
1090 struct brw_reg dest
,
1093 GLuint bind_table_index
)
1095 /* XXX: relAddr not implemented */
1096 GLuint msg_reg_nr
= 1;
1099 brw_push_insn_state(p
);
1100 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1101 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1102 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
1104 /* Setup MRF[1] with location/offset into const buffer */
1105 b
= brw_message_reg(msg_reg_nr
);
1106 b
= retype(b
, BRW_REGISTER_TYPE_UD
);
1107 /* XXX I think we're setting all the dwords of MRF[1] to 'location'.
1108 * when the docs say only dword[2] should be set. Hmmm. But it works.
1110 brw_MOV(p
, b
, brw_imm_ud(location
));
1111 brw_pop_insn_state(p
);
1115 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1117 insn
->header
.predicate_control
= BRW_PREDICATE_NONE
;
1118 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1119 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1120 insn
->header
.mask_control
= BRW_MASK_DISABLE
;
1122 /* cast dest to a uword[8] vector */
1123 dest
= retype(vec8(dest
), BRW_REGISTER_TYPE_UW
);
1125 brw_set_dest(insn
, dest
);
1126 brw_set_src0(insn
, brw_null_reg());
1128 brw_set_dp_read_message(p
->brw
,
1131 0, /* msg_control (0 means 1 Oword) */
1132 BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ
, /* msg_type */
1133 0, /* source cache = data cache */
1135 1, /* response_length (1 Oword) */
1142 * Read float[4] constant(s) from VS constant buffer.
1143 * For relative addressing, two float[4] constants will be read into 'dest'.
1144 * Otherwise, one float[4] constant will be read into the lower half of 'dest'.
1146 void brw_dp_READ_4_vs(struct brw_compile
*p
,
1147 struct brw_reg dest
,
1150 struct brw_reg addrReg
,
1152 GLuint bind_table_index
)
1154 GLuint msg_reg_nr
= 1;
1158 printf("vs const read msg, location %u, msg_reg_nr %d\n",
1159 location, msg_reg_nr);
1162 /* Setup MRF[1] with location/offset into const buffer */
1166 brw_push_insn_state(p
);
1167 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1168 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
1169 brw_set_predicate_control(p
, BRW_PREDICATE_NONE
);
1170 /*brw_set_access_mode(p, BRW_ALIGN_16);*/
1172 /* XXX I think we're setting all the dwords of MRF[1] to 'location'.
1173 * when the docs say only dword[2] should be set. Hmmm. But it works.
1175 b
= brw_message_reg(msg_reg_nr
);
1176 b
= retype(b
, BRW_REGISTER_TYPE_UD
);
1177 /*b = get_element_ud(b, 2);*/
1179 brw_ADD(p
, b
, addrReg
, brw_imm_ud(location
));
1182 brw_MOV(p
, b
, brw_imm_ud(location
));
1185 brw_pop_insn_state(p
);
1189 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1191 insn
->header
.predicate_control
= BRW_PREDICATE_NONE
;
1192 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1193 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1194 insn
->header
.mask_control
= BRW_MASK_DISABLE
;
1195 /*insn->header.access_mode = BRW_ALIGN_16;*/
1197 brw_set_dest(insn
, dest
);
1198 brw_set_src0(insn
, brw_null_reg());
1200 brw_set_dp_read_message(p
->brw
,
1203 oword
, /* 0 = lower Oword, 1 = upper Oword */
1204 BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ
, /* msg_type */
1205 0, /* source cache = data cache */
1207 1, /* response_length (1 Oword) */
1214 void brw_fb_WRITE(struct brw_compile
*p
,
1215 struct brw_reg dest
,
1217 struct brw_reg src0
,
1218 GLuint binding_table_index
,
1220 GLuint response_length
,
1223 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1225 insn
->header
.predicate_control
= 0; /* XXX */
1226 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1227 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1229 brw_set_dest(insn
, dest
);
1230 brw_set_src0(insn
, src0
);
1231 brw_set_dp_write_message(p
->brw
,
1233 binding_table_index
,
1234 BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE
, /* msg_control */
1235 BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE
, /* msg_type */
1237 1, /* pixel scoreboard */
1244 * Texture sample instruction.
1245 * Note: the msg_type plus msg_length values determine exactly what kind
1246 * of sampling operation is performed. See volume 4, page 161 of docs.
1248 void brw_SAMPLE(struct brw_compile
*p
,
1249 struct brw_reg dest
,
1251 struct brw_reg src0
,
1252 GLuint binding_table_index
,
1256 GLuint response_length
,
1259 GLuint header_present
,
1262 GLboolean need_stall
= 0;
1264 if (writemask
== 0) {
1265 /*_mesa_printf("%s: zero writemask??\n", __FUNCTION__); */
1269 /* Hardware doesn't do destination dependency checking on send
1270 * instructions properly. Add a workaround which generates the
1271 * dependency by other means. In practice it seems like this bug
1272 * only crops up for texture samples, and only where registers are
1273 * written by the send and then written again later without being
1274 * read in between. Luckily for us, we already track that
1275 * information and use it to modify the writemask for the
1276 * instruction, so that is a guide for whether a workaround is
1279 if (writemask
!= WRITEMASK_XYZW
) {
1280 GLuint dst_offset
= 0;
1281 GLuint i
, newmask
= 0, len
= 0;
1283 for (i
= 0; i
< 4; i
++) {
1284 if (writemask
& (1<<i
))
1288 for (; i
< 4; i
++) {
1289 if (!(writemask
& (1<<i
)))
1295 if (newmask
!= writemask
) {
1297 /* _mesa_printf("need stall %x %x\n", newmask , writemask); */
1300 struct brw_reg m1
= brw_message_reg(msg_reg_nr
);
1302 newmask
= ~newmask
& WRITEMASK_XYZW
;
1304 brw_push_insn_state(p
);
1306 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1307 brw_set_mask_control(p
, BRW_MASK_DISABLE
);
1309 brw_MOV(p
, m1
, brw_vec8_grf(0,0));
1310 brw_MOV(p
, get_element_ud(m1
, 2), brw_imm_ud(newmask
<< 12));
1312 brw_pop_insn_state(p
);
1314 src0
= retype(brw_null_reg(), BRW_REGISTER_TYPE_UW
);
1315 dest
= offset(dest
, dst_offset
);
1316 response_length
= len
* 2;
1321 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1323 insn
->header
.predicate_control
= 0; /* XXX */
1324 insn
->header
.compression_control
= BRW_COMPRESSION_NONE
;
1325 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1327 brw_set_dest(insn
, dest
);
1328 brw_set_src0(insn
, src0
);
1329 brw_set_sampler_message(p
->brw
, insn
,
1330 binding_table_index
,
1341 struct brw_reg reg
= vec8(offset(dest
, response_length
-1));
1343 /* mov (8) r9.0<1>:f r9.0<8;8,1>:f { Align1 }
1345 brw_push_insn_state(p
);
1346 brw_set_compression_control(p
, BRW_COMPRESSION_NONE
);
1347 brw_MOV(p
, reg
, reg
);
1348 brw_pop_insn_state(p
);
1353 /* All these variables are pretty confusing - we might be better off
1354 * using bitmasks and macros for this, in the old style. Or perhaps
1355 * just having the caller instantiate the fields in dword3 itself.
1357 void brw_urb_WRITE(struct brw_compile
*p
,
1358 struct brw_reg dest
,
1360 struct brw_reg src0
,
1364 GLuint response_length
,
1366 GLboolean writes_complete
,
1370 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1372 assert(msg_length
< BRW_MAX_MRF
);
1374 brw_set_dest(insn
, dest
);
1375 brw_set_src0(insn
, src0
);
1376 brw_set_src1(insn
, brw_imm_d(0));
1378 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1380 brw_set_urb_message(p
->brw
,
1392 void brw_ff_sync(struct brw_compile
*p
,
1393 struct brw_reg dest
,
1395 struct brw_reg src0
,
1399 GLuint response_length
,
1401 GLboolean writes_complete
,
1405 struct brw_instruction
*insn
= next_insn(p
, BRW_OPCODE_SEND
);
1407 assert(msg_length
< 16);
1409 brw_set_dest(insn
, dest
);
1410 brw_set_src0(insn
, src0
);
1411 brw_set_src1(insn
, brw_imm_d(0));
1413 insn
->header
.destreg__conditonalmod
= msg_reg_nr
;
1415 brw_set_ff_sync_message(p
->brw
,