2 * Mesa 3-D graphics library
4 * Copyright (C) 2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
31 #include "ilo_common.h"
32 #include "ilo_state.h"
38 struct ilo_state_vector
;
40 enum ilo_render_invalidate_flags
{
41 ILO_RENDER_INVALIDATE_HW
= 1 << 0,
42 ILO_RENDER_INVALIDATE_BATCH_BO
= 1 << 1,
43 ILO_RENDER_INVALIDATE_STATE_BO
= 1 << 2,
44 ILO_RENDER_INVALIDATE_KERNEL_BO
= 1 << 3,
46 ILO_RENDER_INVALIDATE_ALL
= 0xffffffff,
49 enum ilo_render_action
{
60 const struct ilo_dev_info
*dev
;
61 struct ilo_builder
*builder
;
63 uint32_t invalidate_flags
;
65 struct intel_bo
*workaround_bo
;
67 uint32_t packed_sample_position_1x
;
68 uint32_t packed_sample_position_4x
;
69 uint32_t packed_sample_position_8x
[2];
71 int (*estimate_size
)(struct ilo_render
*render
,
72 enum ilo_render_action action
,
75 void (*emit_draw
)(struct ilo_render
*render
,
76 const struct ilo_state_vector
*vec
);
78 void (*emit_flush
)(struct ilo_render
*render
);
80 void (*emit_query
)(struct ilo_render
*render
,
81 struct ilo_query
*q
, uint32_t offset
);
83 void (*emit_rectlist
)(struct ilo_render
*render
,
84 const struct ilo_blitter
*blitter
);
89 struct ilo_render_state
{
91 * When a WA is needed before some command, we always emit the WA right
92 * before the command. Knowing what have already been done since last
93 * 3DPRIMITIVE allows us to skip some WAs.
95 uint32_t current_pipe_control_dw1
;
98 * When a WA is needed after some command, we may have the WA follow the
99 * command immediately or defer it. If this is non-zero, a PIPE_CONTROL
100 * will be emitted before 3DPRIMITIVE.
102 uint32_t deferred_pipe_control_dw1
;
104 bool primitive_restart
;
108 uint32_t SF_VIEWPORT
;
109 uint32_t CLIP_VIEWPORT
;
110 uint32_t SF_CLIP_VIEWPORT
; /* GEN7+ */
111 uint32_t CC_VIEWPORT
;
113 uint32_t COLOR_CALC_STATE
;
114 uint32_t BLEND_STATE
;
115 uint32_t DEPTH_STENCIL_STATE
;
117 uint32_t SCISSOR_RECT
;
120 uint32_t BINDING_TABLE_STATE
;
121 int BINDING_TABLE_STATE_size
;
122 uint32_t SURFACE_STATE
[ILO_MAX_VS_SURFACES
];
123 uint32_t SAMPLER_STATE
;
124 uint32_t SAMPLER_BORDER_COLOR_STATE
[ILO_MAX_SAMPLERS
];
125 uint32_t PUSH_CONSTANT_BUFFER
;
126 int PUSH_CONSTANT_BUFFER_size
;
130 uint32_t BINDING_TABLE_STATE
;
131 int BINDING_TABLE_STATE_size
;
132 uint32_t SURFACE_STATE
[ILO_MAX_GS_SURFACES
];
137 uint32_t BINDING_TABLE_STATE
;
138 int BINDING_TABLE_STATE_size
;
139 uint32_t SURFACE_STATE
[ILO_MAX_WM_SURFACES
];
140 uint32_t SAMPLER_STATE
;
141 uint32_t SAMPLER_BORDER_COLOR_STATE
[ILO_MAX_SAMPLERS
];
142 uint32_t PUSH_CONSTANT_BUFFER
;
143 int PUSH_CONSTANT_BUFFER_size
;
149 ilo_render_create(struct ilo_builder
*builder
);
152 ilo_render_destroy(struct ilo_render
*render
);
156 ilo_render_invalidate(struct ilo_render
*render
, uint32_t flags
)
158 render
->invalidate_flags
|= flags
;
160 /* Kernel flushes everything. Shouldn't we set all bits here? */
161 render
->state
.current_pipe_control_dw1
= 0;
165 * Estimate the size of an action.
168 ilo_render_estimate_size(struct ilo_render
*render
,
169 enum ilo_render_action action
,
172 return render
->estimate_size(render
, action
, arg
);
176 * Emit context states and 3DPRIMITIVE.
179 ilo_render_emit_draw(struct ilo_render
*render
,
180 const struct ilo_state_vector
*vec
)
182 render
->emit_draw(render
, vec
);
186 * Emit PIPE_CONTROL to flush all caches.
189 ilo_render_emit_flush(struct ilo_render
*render
)
191 render
->emit_flush(render
);
195 * Emit PIPE_CONTROL or MI_STORE_REGISTER_MEM to save register values.
198 ilo_render_emit_query(struct ilo_render
*render
,
199 struct ilo_query
*q
, uint32_t offset
)
201 render
->emit_query(render
, q
, offset
);
205 ilo_render_emit_rectlist(struct ilo_render
*render
,
206 const struct ilo_blitter
*blitter
)
208 render
->emit_rectlist(render
, blitter
);
212 ilo_render_get_sample_position(struct ilo_render
*render
,
213 unsigned sample_count
,
214 unsigned sample_index
,
217 #endif /* ILO_RENDER_H */