682611223173fa0e15608aa4cb4df0a132fbfe43
2 * Copyright © 2006 - 2017 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
26 #include "dev/gen_debug.h"
29 brw_compile_clip(const struct brw_compiler
*compiler
,
31 const struct brw_clip_prog_key
*key
,
32 struct brw_clip_prog_data
*prog_data
,
33 struct brw_vue_map
*vue_map
,
34 unsigned *final_assembly_size
)
36 struct brw_clip_compile c
;
37 memset(&c
, 0, sizeof(c
));
39 /* Begin the compilation:
41 brw_init_codegen(compiler
->devinfo
, &c
.func
, mem_ctx
);
43 c
.func
.single_program_flow
= 1;
48 /* nr_regs is the number of registers filled by reading data from the VUE.
49 * This program accesses the entire VUE, so nr_regs needs to be the size of
50 * the VUE (measured in pairs, since two slots are stored in each
53 c
.nr_regs
= (c
.vue_map
.num_slots
+ 1)/2;
55 c
.prog_data
.clip_mode
= c
.key
.clip_mode
; /* XXX */
57 /* For some reason the thread is spawned with only 4 channels
60 brw_set_default_mask_control(&c
.func
, BRW_MASK_DISABLE
);
62 /* Would ideally have the option of producing a program which could
65 switch (key
->primitive
) {
68 brw_emit_unfilled_clip( &c
);
70 brw_emit_tri_clip( &c
);
73 brw_emit_line_clip( &c
);
76 brw_emit_point_clip( &c
);
79 unreachable("not reached");
82 brw_compact_instructions(&c
.func
, 0, NULL
);
84 *prog_data
= c
.prog_data
;
86 const unsigned *program
= brw_get_program(&c
.func
, final_assembly_size
);
88 if (unlikely(INTEL_DEBUG
& DEBUG_CLIP
)) {
89 fprintf(stderr
, "clip:\n");
90 brw_disassemble(compiler
->devinfo
,
91 program
, 0, *final_assembly_size
, stderr
);
92 fprintf(stderr
, "\n");