clover: Define helper classes for the new object model.
[mesa.git] / src / gallium / drivers / ilo / ilo_3d_pipeline.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_3D_PIPELINE_H
29 #define ILO_3D_PIPELINE_H
30
31 #include "ilo_common.h"
32 #include "ilo_gpe.h"
33
34 struct intel_bo;
35 struct ilo_cp;
36 struct ilo_context;
37
38 enum ilo_3d_pipeline_invalidate_flags {
39 ILO_3D_PIPELINE_INVALIDATE_HW = 1 << 0,
40 ILO_3D_PIPELINE_INVALIDATE_BATCH_BO = 1 << 1,
41 ILO_3D_PIPELINE_INVALIDATE_STATE_BO = 1 << 2,
42 ILO_3D_PIPELINE_INVALIDATE_KERNEL_BO = 1 << 3,
43
44 ILO_3D_PIPELINE_INVALIDATE_ALL = 0xffffffff,
45 };
46
47 enum ilo_3d_pipeline_action {
48 ILO_3D_PIPELINE_DRAW,
49 ILO_3D_PIPELINE_FLUSH,
50 ILO_3D_PIPELINE_WRITE_TIMESTAMP,
51 ILO_3D_PIPELINE_WRITE_DEPTH_COUNT,
52 };
53
54 /**
55 * 3D pipeline.
56 */
57 struct ilo_3d_pipeline {
58 struct ilo_cp *cp;
59 const struct ilo_dev_info *dev;
60
61 uint32_t invalidate_flags;
62
63 struct intel_bo *workaround_bo;
64
65 uint32_t packed_sample_position_1x;
66 uint32_t packed_sample_position_4x;
67 uint32_t packed_sample_position_8x[2];
68
69 int (*estimate_size)(struct ilo_3d_pipeline *pipeline,
70 enum ilo_3d_pipeline_action action,
71 const void *arg);
72
73 void (*emit_draw)(struct ilo_3d_pipeline *pipeline,
74 const struct ilo_context *ilo);
75
76 void (*emit_flush)(struct ilo_3d_pipeline *pipeline);
77
78 void (*emit_write_timestamp)(struct ilo_3d_pipeline *pipeline,
79 struct intel_bo *bo, int index);
80
81 void (*emit_write_depth_count)(struct ilo_3d_pipeline *pipeline,
82 struct intel_bo *bo, int index);
83
84 /**
85 * HW states.
86 */
87 struct ilo_3d_pipeline_state {
88 bool has_gen6_wa_pipe_control;
89
90 bool primitive_restart;
91 int reduced_prim;
92 int so_num_vertices, so_max_vertices;
93
94 uint32_t SF_VIEWPORT;
95 uint32_t CLIP_VIEWPORT;
96 uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */
97 uint32_t CC_VIEWPORT;
98
99 uint32_t COLOR_CALC_STATE;
100 uint32_t BLEND_STATE;
101 uint32_t DEPTH_STENCIL_STATE;
102
103 uint32_t SCISSOR_RECT;
104
105 struct {
106 uint32_t BINDING_TABLE_STATE;
107 int BINDING_TABLE_STATE_size;
108 uint32_t SURFACE_STATE[ILO_MAX_VS_SURFACES];
109 uint32_t SAMPLER_STATE;
110 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
111 uint32_t PUSH_CONSTANT_BUFFER;
112 int PUSH_CONSTANT_BUFFER_size;
113 } vs;
114
115 struct {
116 uint32_t BINDING_TABLE_STATE;
117 int BINDING_TABLE_STATE_size;
118 uint32_t SURFACE_STATE[ILO_MAX_GS_SURFACES];
119 bool active;
120 } gs;
121
122 struct {
123 uint32_t BINDING_TABLE_STATE;
124 int BINDING_TABLE_STATE_size;
125 uint32_t SURFACE_STATE[ILO_MAX_WM_SURFACES];
126 uint32_t SAMPLER_STATE;
127 uint32_t SAMPLER_BORDER_COLOR_STATE[ILO_MAX_SAMPLERS];
128 uint32_t PUSH_CONSTANT_BUFFER;
129 int PUSH_CONSTANT_BUFFER_size;
130 } wm;
131 } state;
132 };
133
134 struct ilo_3d_pipeline *
135 ilo_3d_pipeline_create(struct ilo_cp *cp, const struct ilo_dev_info *dev);
136
137 void
138 ilo_3d_pipeline_destroy(struct ilo_3d_pipeline *pipeline);
139
140
141 static inline void
142 ilo_3d_pipeline_invalidate(struct ilo_3d_pipeline *p, uint32_t flags)
143 {
144 p->invalidate_flags |= flags;
145 }
146
147 /**
148 * Estimate the size of an action.
149 */
150 static inline int
151 ilo_3d_pipeline_estimate_size(struct ilo_3d_pipeline *pipeline,
152 enum ilo_3d_pipeline_action action,
153 const void *arg)
154 {
155 return pipeline->estimate_size(pipeline, action, arg);
156 }
157
158 bool
159 ilo_3d_pipeline_emit_draw(struct ilo_3d_pipeline *p,
160 const struct ilo_context *ilo,
161 int *prim_generated, int *prim_emitted);
162
163 void
164 ilo_3d_pipeline_emit_flush(struct ilo_3d_pipeline *p);
165
166 void
167 ilo_3d_pipeline_emit_write_timestamp(struct ilo_3d_pipeline *p,
168 struct intel_bo *bo, int index);
169
170 void
171 ilo_3d_pipeline_emit_write_depth_count(struct ilo_3d_pipeline *p,
172 struct intel_bo *bo, int index);
173
174 void
175 ilo_3d_pipeline_get_sample_position(struct ilo_3d_pipeline *p,
176 unsigned sample_count,
177 unsigned sample_index,
178 float *x, float *y);
179
180 void
181 ilo_3d_pipeline_dump(struct ilo_3d_pipeline *p);
182
183 #endif /* ILO_3D_PIPELINE_H */