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 "util/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
,
30 : mem_ctx(ralloc_context(NULL
)),
31 generator(brw
, mem_ctx
,
32 rzalloc(mem_ctx
, struct brw_wm_prog_key
),
33 rzalloc(mem_ctx
, struct brw_wm_prog_data
),
34 NULL
, NULL
, false, false, debug_flag
)
38 brw_blorp_eu_emitter::~brw_blorp_eu_emitter()
44 brw_blorp_eu_emitter::get_program(unsigned *program_size
)
46 return generator
.generate_assembly(NULL
, &insts
, program_size
);
50 * Emit code that kills pixels whose X and Y coordinates are outside the
51 * boundary of the rectangle defined by the push constants (dst_x0, dst_y0,
55 brw_blorp_eu_emitter::emit_kill_if_outside_rect(const struct brw_reg
&x
,
56 const struct brw_reg
&y
,
57 const struct brw_reg
&dst_x0
,
58 const struct brw_reg
&dst_x1
,
59 const struct brw_reg
&dst_y0
,
60 const struct brw_reg
&dst_y1
)
62 struct brw_reg f0
= brw_flag_reg(0, 0);
63 struct brw_reg g1
= retype(brw_vec1_grf(1, 7), BRW_REGISTER_TYPE_UW
);
65 emit_cmp(BRW_CONDITIONAL_GE
, x
, dst_x0
);
66 emit_cmp(BRW_CONDITIONAL_GE
, y
, dst_y0
)->predicate
= BRW_PREDICATE_NORMAL
;
67 emit_cmp(BRW_CONDITIONAL_L
, x
, dst_x1
)->predicate
= BRW_PREDICATE_NORMAL
;
68 emit_cmp(BRW_CONDITIONAL_L
, y
, dst_y1
)->predicate
= BRW_PREDICATE_NORMAL
;
70 fs_inst
*inst
= new (mem_ctx
) fs_inst(BRW_OPCODE_AND
, g1
, f0
, g1
);
71 inst
->force_writemask_all
= true;
72 insts
.push_tail(inst
);
76 brw_blorp_eu_emitter::emit_texture_lookup(const struct brw_reg
&dst
,
81 fs_inst
*inst
= new (mem_ctx
) fs_inst(op
, dst
, brw_message_reg(base_mrf
),
84 inst
->base_mrf
= base_mrf
;
85 inst
->mlen
= msg_length
;
87 inst
->header_present
= false;
89 insts
.push_tail(inst
);
93 brw_blorp_eu_emitter::emit_render_target_write(const struct brw_reg
&src0
,
98 fs_inst
*inst
= new (mem_ctx
) fs_inst(FS_OPCODE_BLORP_FB_WRITE
);
101 inst
->base_mrf
= msg_reg_nr
;
102 inst
->mlen
= msg_length
;
103 inst
->header_present
= use_header
;
104 inst
->target
= BRW_BLORP_RENDERBUFFER_BINDING_TABLE_INDEX
;
106 insts
.push_tail(inst
);
110 brw_blorp_eu_emitter::emit_combine(enum opcode combine_opcode
,
111 const struct brw_reg
&dst
,
112 const struct brw_reg
&src_1
,
113 const struct brw_reg
&src_2
)
115 assert(combine_opcode
== BRW_OPCODE_ADD
|| combine_opcode
== BRW_OPCODE_AVG
);
117 insts
.push_tail(new (mem_ctx
) fs_inst(combine_opcode
, dst
, src_1
, src_2
));
121 brw_blorp_eu_emitter::emit_cmp(enum brw_conditional_mod op
,
122 const struct brw_reg
&x
,
123 const struct brw_reg
&y
)
125 fs_inst
*cmp
= new (mem_ctx
) fs_inst(BRW_OPCODE_CMP
,
126 vec16(brw_null_reg()), x
, y
);
127 cmp
->conditional_mod
= op
;
128 insts
.push_tail(cmp
);