ilo: make ilo_render_emit_draw() direct
[mesa.git] / src / gallium / drivers / ilo / ilo_render.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2013 LunarG, Inc.
5 *
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:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
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.
23 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
26 */
27
28 #ifndef ILO_RENDER_H
29 #define ILO_RENDER_H
30
31 #include "ilo_common.h"
32 #include "ilo_state.h"
33
34 struct intel_bo;
35 struct ilo_blitter;
36 struct ilo_cp;
37 struct ilo_query;
38 struct ilo_state_vector;
39
40 /**
41 * Render Engine.
42 */
43 struct ilo_render {
44 const struct ilo_dev_info *dev;
45 struct ilo_builder *builder;
46
47 struct intel_bo *workaround_bo;
48
49 uint32_t packed_sample_position_1x;
50 uint32_t packed_sample_position_4x;
51 uint32_t packed_sample_position_8x[2];
52
53 bool hw_ctx_changed;
54
55 /*
56 * Any state that involves resources needs to be re-emitted when the
57 * batch bo changed. This is because we do not pin the resources and
58 * their offsets (or existence) may change between batch buffers.
59 */
60 bool batch_bo_changed;
61 bool state_bo_changed;
62 bool instruction_bo_changed;
63
64 /**
65 * HW states.
66 */
67 struct ilo_render_state {
68 /*
69 * When a WA is needed before some command, we always emit the WA right
70 * before the command. Knowing what have already been done since last
71 * 3DPRIMITIVE allows us to skip some WAs.
72 */
73 uint32_t current_pipe_control_dw1;
74
75 /*
76 * When a WA is needed after some command, we may have the WA follow the
77 * command immediately or defer it. If this is non-zero, a PIPE_CONTROL
78 * will be emitted before 3DPRIMITIVE.
79 */
80 uint32_t deferred_pipe_control_dw1;
81
82 bool primitive_restart;
83 int reduced_prim;
84 int so_max_vertices;
85
86 uint32_t SF_VIEWPORT;
87 uint32_t CLIP_VIEWPORT;
88 uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */
89 uint32_t CC_VIEWPORT;
90
91 uint32_t COLOR_CALC_STATE;
92 uint32_t BLEND_STATE;
93 uint32_t DEPTH_STENCIL_STATE;
94
95 uint32_t SCISSOR_RECT;
96
97 struct {
98 uint32_t BINDING_TABLE_STATE;
99 int BINDING_TABLE_STATE_size;
100 uint32_t SURFACE_STATE[ILO_MAX_VS_SURFACES];
101 uint32_t SAMPLER_STATE;
102 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
103 uint32_t PUSH_CONSTANT_BUFFER;
104 int PUSH_CONSTANT_BUFFER_size;
105 } vs;
106
107 struct {
108 uint32_t BINDING_TABLE_STATE;
109 int BINDING_TABLE_STATE_size;
110 uint32_t SURFACE_STATE[ILO_MAX_GS_SURFACES];
111 bool active;
112 } gs;
113
114 struct {
115 uint32_t BINDING_TABLE_STATE;
116 int BINDING_TABLE_STATE_size;
117 uint32_t SURFACE_STATE[ILO_MAX_WM_SURFACES];
118 uint32_t SAMPLER_STATE;
119 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
120 uint32_t PUSH_CONSTANT_BUFFER;
121 int PUSH_CONSTANT_BUFFER_size;
122 } wm;
123 } state;
124 };
125
126 struct ilo_render *
127 ilo_render_create(struct ilo_builder *builder);
128
129 void
130 ilo_render_destroy(struct ilo_render *render);
131
132 /**
133 * Estimate the size of an action.
134 */
135 void
136 ilo_render_get_sample_position(const struct ilo_render *render,
137 unsigned sample_count,
138 unsigned sample_index,
139 float *x, float *y);
140
141 void
142 ilo_render_invalidate_hw(struct ilo_render *render);
143
144 void
145 ilo_render_invalidate_builder(struct ilo_render *render);
146
147 int
148 ilo_render_get_flush_len(const struct ilo_render *render);
149
150 void
151 ilo_render_emit_flush(struct ilo_render *render);
152
153 int
154 ilo_render_get_query_len(const struct ilo_render *render,
155 unsigned query_type);
156
157 void
158 ilo_render_emit_query(struct ilo_render *render,
159 struct ilo_query *q, uint32_t offset);
160
161 int
162 ilo_render_get_rectlist_len(const struct ilo_render *render,
163 const struct ilo_blitter *blitter);
164
165 void
166 ilo_render_emit_rectlist(struct ilo_render *render,
167 const struct ilo_blitter *blitter);
168
169 int
170 ilo_render_get_draw_len(const struct ilo_render *render,
171 const struct ilo_state_vector *vec);
172
173 void
174 ilo_render_emit_draw(struct ilo_render *render,
175 const struct ilo_state_vector *vec);
176
177 #endif /* ILO_RENDER_H */