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>
32 #include "util/u_math.h"
34 #include "brw_context.h"
35 #include "brw_state.h"
36 #include "brw_defines.h"
37 #include "brw_debug.h"
39 struct brw_gs_unit_key
{
40 unsigned int total_grf
;
41 unsigned int urb_entry_read_length
;
43 unsigned int curbe_offset
;
45 unsigned int nr_urb_entries
, urb_size
;
46 GLboolean prog_active
;
50 gs_unit_populate_key(struct brw_context
*brw
, struct brw_gs_unit_key
*key
)
52 memset(key
, 0, sizeof(*key
));
54 /* CACHE_NEW_GS_PROG */
55 key
->prog_active
= brw
->gs
.prog_active
;
56 if (key
->prog_active
) {
57 key
->total_grf
= brw
->gs
.prog_data
->total_grf
;
58 key
->urb_entry_read_length
= brw
->gs
.prog_data
->urb_read_length
;
61 key
->urb_entry_read_length
= 1;
64 /* BRW_NEW_CURBE_OFFSETS */
65 key
->curbe_offset
= brw
->curbe
.clip_start
;
67 /* BRW_NEW_URB_FENCE */
68 key
->nr_urb_entries
= brw
->urb
.nr_gs_entries
;
69 key
->urb_size
= brw
->urb
.vsize
;
72 static enum pipe_error
73 gs_unit_create_from_key(struct brw_context
*brw
,
74 struct brw_gs_unit_key
*key
,
75 struct brw_winsys_reloc
*reloc
,
77 struct brw_winsys_buffer
**bo_out
)
79 struct brw_gs_unit_state gs
;
83 memset(&gs
, 0, sizeof(gs
));
86 gs
.thread0
.grf_reg_count
= align(key
->total_grf
, 16) / 16 - 1;
87 gs
.thread0
.kernel_start_pointer
= 0;
89 gs
.thread1
.floating_point_mode
= BRW_FLOATING_POINT_NON_IEEE_754
;
90 gs
.thread1
.single_program_flow
= 1;
92 gs
.thread3
.dispatch_grf_start_reg
= 1;
93 gs
.thread3
.const_urb_entry_read_offset
= 0;
94 gs
.thread3
.const_urb_entry_read_length
= 0;
95 gs
.thread3
.urb_entry_read_offset
= 0;
96 gs
.thread3
.urb_entry_read_length
= key
->urb_entry_read_length
;
98 gs
.thread4
.nr_urb_entries
= key
->nr_urb_entries
;
99 gs
.thread4
.urb_entry_allocation_size
= key
->urb_size
- 1;
101 if (key
->nr_urb_entries
>= 8)
102 gs
.thread4
.max_threads
= 1;
104 gs
.thread4
.max_threads
= 0;
106 if (BRW_IS_IGDNG(brw
))
107 gs
.thread4
.rendering_enable
= 1;
109 if (BRW_DEBUG
& DEBUG_STATS
)
110 gs
.thread4
.stats_enable
= 1;
112 ret
= brw_upload_cache(&brw
->cache
, BRW_GS_UNIT
,
124 static enum pipe_error
prepare_gs_unit(struct brw_context
*brw
)
126 struct brw_gs_unit_key key
;
128 struct brw_winsys_reloc reloc
[1];
129 unsigned nr_reloc
= 0;
130 unsigned grf_reg_count
;
132 gs_unit_populate_key(brw
, &key
);
134 grf_reg_count
= (align(key
.total_grf
, 16) / 16 - 1);
136 /* GS program relocation */
137 if (key
.prog_active
) {
138 make_reloc(&reloc
[nr_reloc
++],
141 offsetof(struct brw_gs_unit_state
, thread0
),
145 if (brw_search_cache(&brw
->cache
, BRW_GS_UNIT
,
152 ret
= gs_unit_create_from_key(brw
, &key
,
161 const struct brw_tracked_state brw_gs_unit
= {
164 .brw
= (BRW_NEW_CURBE_OFFSETS
|
166 .cache
= CACHE_NEW_GS_PROG
168 .prepare
= prepare_gs_unit
,