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_action
{
51 const struct ilo_dev_info
*dev
;
52 struct ilo_builder
*builder
;
54 struct intel_bo
*workaround_bo
;
56 uint32_t packed_sample_position_1x
;
57 uint32_t packed_sample_position_4x
;
58 uint32_t packed_sample_position_8x
[2];
60 int (*estimate_size
)(struct ilo_render
*render
,
61 enum ilo_render_action action
,
64 void (*emit_draw
)(struct ilo_render
*render
,
65 const struct ilo_state_vector
*vec
);
67 void (*emit_flush
)(struct ilo_render
*render
);
69 void (*emit_query
)(struct ilo_render
*render
,
70 struct ilo_query
*q
, uint32_t offset
);
72 void (*emit_rectlist
)(struct ilo_render
*render
,
73 const struct ilo_blitter
*blitter
);
78 * Any state that involves resources needs to be re-emitted when the
79 * batch bo changed. This is because we do not pin the resources and
80 * their offsets (or existence) may change between batch buffers.
82 bool batch_bo_changed
;
83 bool state_bo_changed
;
84 bool instruction_bo_changed
;
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
);
155 * Estimate the size of an action.
158 ilo_render_estimate_size(struct ilo_render
*render
,
159 enum ilo_render_action action
,
162 return render
->estimate_size(render
, action
, arg
);
166 * Emit context states and 3DPRIMITIVE.
169 ilo_render_emit_draw(struct ilo_render
*render
,
170 const struct ilo_state_vector
*vec
)
172 render
->emit_draw(render
, vec
);
176 * Emit PIPE_CONTROL to flush all caches.
179 ilo_render_emit_flush(struct ilo_render
*render
)
181 render
->emit_flush(render
);
185 * Emit PIPE_CONTROL or MI_STORE_REGISTER_MEM to save register values.
188 ilo_render_emit_query(struct ilo_render
*render
,
189 struct ilo_query
*q
, uint32_t offset
)
191 render
->emit_query(render
, q
, offset
);
195 ilo_render_emit_rectlist(struct ilo_render
*render
,
196 const struct ilo_blitter
*blitter
)
198 render
->emit_rectlist(render
, blitter
);
202 ilo_render_get_sample_position(const struct ilo_render
*render
,
203 unsigned sample_count
,
204 unsigned sample_index
,
208 ilo_render_invalidate_hw(struct ilo_render
*render
);
211 ilo_render_invalidate_builder(struct ilo_render
*render
);
213 #endif /* ILO_RENDER_H */