1 /*
2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
5
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:
13
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.
17
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.
25
26 **********************************************************************/
27 /*
28 * Authors:
29 * Keith Whitwell <keith@tungstengraphics.com>
30 */
31
32
33
34 #include "brw_context.h"
35 #include "brw_state.h"
36 #include "brw_defines.h"
37
38 static void
brw_upload_gs_unit(struct brw_context * brw)39 brw_upload_gs_unit(struct brw_context *brw)
40 {
41 struct intel_context *intel = &brw->intel;
42 struct brw_gs_unit_state *gs;
43
44 gs = brw_state_batch(brw, AUB_TRACE_GS_STATE,
45 sizeof(*gs), 32, &brw->gs.state_offset);
46
47 memset(gs, 0, sizeof(*gs));
48
49 /* BRW_NEW_PROGRAM_CACHE | CACHE_NEW_GS_PROG */
50 if (brw->gs.prog_active) {
51 gs->thread0.grf_reg_count = (ALIGN(brw->gs.prog_data->total_grf, 16) /
52 16 - 1);
53
54 gs->thread0.kernel_start_pointer =
55 brw_program_reloc(brw,
56 brw->gs.state_offset +
57 offsetof(struct brw_gs_unit_state, thread0),
58 brw->gs.prog_offset +
59 (gs->thread0.grf_reg_count << 1)) >> 6;
60
61 gs->thread1.floating_point_mode = BRW_FLOATING_POINT_NON_IEEE_754;
62 gs->thread1.single_program_flow = 1;
63
64 gs->thread3.dispatch_grf_start_reg = 1;
65 gs->thread3.const_urb_entry_read_offset = 0;
66 gs->thread3.const_urb_entry_read_length = 0;
67 gs->thread3.urb_entry_read_offset = 0;
68 gs->thread3.urb_entry_read_length = brw->gs.prog_data->urb_read_length;
69
70 /* BRW_NEW_URB_FENCE */
71 gs->thread4.nr_urb_entries = brw->urb.nr_gs_entries;
72 gs->thread4.urb_entry_allocation_size = brw->urb.vsize - 1;
73
74 if (brw->urb.nr_gs_entries >= 8)
75 gs->thread4.max_threads = 1;
76 else
77 gs->thread4.max_threads = 0;
78 }
79
80 if (intel->gen == 5)
81 gs->thread4.rendering_enable = 1;
82
83 if (unlikely(INTEL_DEBUG & DEBUG_STATS))
84 gs->thread4.stats_enable = 1;
85
86 brw->state.dirty.cache |= CACHE_NEW_GS_UNIT;
87 }
88
89 const struct brw_tracked_state brw_gs_unit = {
90 .dirty = {
91 .mesa = 0,
92 .brw = (BRW_NEW_BATCH |
93 BRW_NEW_PROGRAM_CACHE |
94 BRW_NEW_CURBE_OFFSETS |
95 BRW_NEW_URB_FENCE),
96 .cache = CACHE_NEW_GS_PROG
97 },
98 .emit = brw_upload_gs_unit,
99 };
100