2 * Copyright © 2013 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "glsl/ralloc.h"
25 #include "brw_blorp_blit_eu.h"
26 #include "brw_blorp.h"
28 brw_blorp_eu_emitter::brw_blorp_eu_emitter(struct brw_context
*brw
)
29 : mem_ctx(ralloc_context(NULL
))
31 brw_init_compile(brw
, &func
, mem_ctx
);
34 * By default everything is emitted as 16-wide with only a few expections
35 * handled explicitly either here in the compiler or by one of the specific
36 * code emission calls.
37 * It should be also noted that here in this file any alterations of the
38 * compression control settings are only used to affect the execution size
39 * of the instructions. The instruction template used to initialise all the
40 * instructions is effectively not altered -- the value stays at zero
41 * representing either GEN6_COMPRESSION_1Q or GEN6_COMPRESSION_1H depending
43 * If any other settings are used in the instruction headers, they are set
44 * elsewhere by the individual code emission calls.
46 brw_set_compression_control(&func
, BRW_COMPRESSION_COMPRESSED
);
49 brw_blorp_eu_emitter::~brw_blorp_eu_emitter()
55 brw_blorp_eu_emitter::get_program(unsigned *program_size
, FILE *dump_file
)
57 brw_set_uip_jip(&func
);
59 if (unlikely(INTEL_DEBUG
& DEBUG_BLORP
)) {
60 printf("Native code for BLORP blit:\n");
61 brw_dump_compile(&func
, dump_file
, 0, func
.next_insn_offset
);
65 return brw_get_program(&func
, program_size
);
69 * Emit code that kills pixels whose X and Y coordinates are outside the
70 * boundary of the rectangle defined by the push constants (dst_x0, dst_y0,
74 brw_blorp_eu_emitter::emit_kill_if_outside_rect(const struct brw_reg
&x
,
75 const struct brw_reg
&y
,
76 const struct brw_reg
&dst_x0
,
77 const struct brw_reg
&dst_x1
,
78 const struct brw_reg
&dst_y0
,
79 const struct brw_reg
&dst_y1
)
81 struct brw_reg f0
= brw_flag_reg(0, 0);
82 struct brw_reg g1
= retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW
);
83 struct brw_reg null32
= vec16(retype(brw_null_reg(), BRW_REGISTER_TYPE_UD
));
85 brw_CMP(&func
, null32
, BRW_CONDITIONAL_GE
, x
, dst_x0
);
86 brw_CMP(&func
, null32
, BRW_CONDITIONAL_GE
, y
, dst_y0
);
87 brw_CMP(&func
, null32
, BRW_CONDITIONAL_L
, x
, dst_x1
);
88 brw_CMP(&func
, null32
, BRW_CONDITIONAL_L
, y
, dst_y1
);
90 brw_set_predicate_control(&func
, BRW_PREDICATE_NONE
);
92 struct brw_instruction
*inst
= brw_AND(&func
, g1
, f0
, g1
);
93 inst
->header
.mask_control
= BRW_MASK_DISABLE
;
97 brw_blorp_eu_emitter::emit_texture_lookup(const struct brw_reg
&dst
,
105 case SHADER_OPCODE_TEX
:
106 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE
;
108 case SHADER_OPCODE_TXF
:
109 msg_type
= GEN5_SAMPLER_MESSAGE_SAMPLE_LD
;
111 case SHADER_OPCODE_TXF_CMS
:
112 msg_type
= GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DMS
;
114 case SHADER_OPCODE_TXF_UMS
:
115 msg_type
= GEN7_SAMPLER_MESSAGE_SAMPLE_LD2DSS
;
117 case SHADER_OPCODE_TXF_MCS
:
118 msg_type
= GEN7_SAMPLER_MESSAGE_SAMPLE_LD_MCS
;
121 assert(!"Unsupported texture lookup operation");
125 retype(dst
, BRW_REGISTER_TYPE_UW
) /* dest */,
126 base_mrf
/* msg_reg_nr */,
127 brw_message_reg(base_mrf
) /* src0 */,
128 BRW_BLORP_TEXTURE_BINDING_TABLE_INDEX
,
131 8 /* response_length. TODO: should be smaller for non-RGBA formats? */,
133 0 /* header_present */,
134 BRW_SAMPLER_SIMD_MODE_SIMD16
,
135 BRW_SAMPLER_RETURN_FORMAT_FLOAT32
);