blob: 6f826f6bda4283b3b60793ea2575ecfc330f215b [file] [log] [blame]
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -06001/*
2 * XGL
3 *
4 * Copyright (C) 2014 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
25#ifndef PIPELINE_H
26#define PIPELINE_H
27
28#include "intel.h"
29#include "obj.h"
30#include "dev.h"
31
Chia-I Wu1f7540b2014-08-22 13:56:18 +080032#define INTEL_RMAP_SLOT_RT ((XGL_UINT) -1)
33#define INTEL_RMAP_SLOT_DYN ((XGL_UINT) -2)
34struct intel_rmap_slot {
35 /*
36 *
37 * When path_len is 0, the slot is unused.
38 * When path_len is 1, the slot uses descriptor "index".
39 * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index".
40 * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view.
41 * Otherwise, the slot uses "path" to find the descriptor.
42 */
43 XGL_UINT path_len;
44
45 union {
46 XGL_UINT index;
47 XGL_UINT *path;
48 } u;
49};
50
51/**
52 * Shader resource mapping.
53 */
54struct intel_rmap {
55 /* this is not an intel_obj */
56
57 XGL_UINT rt_count;
58 XGL_UINT resource_count;
59 XGL_UINT uav_count;
60 XGL_UINT sampler_count;
61
62 /*
63 * rt_count slots +
64 * resource_count slots +
65 * uav_count slots +
66 * sampler_count slots
67 */
68 struct intel_rmap_slot *slots;
69 XGL_UINT slot_count;
70};
71
Courtney Goeltzenleuchterf21aaab2014-08-28 17:38:09 -060072/**
73 * Implementation limits
74 */
75#define INTEL_MAX_ATTRIBS 32
76#define INTEL_MAX_CLIP_PLANES 8
77#define INTEL_MAX_COLOR_BUFS 8
78#define INTEL_MAX_SHADER_INPUTS 32
79#define INTEL_MAX_SHADER_OUTPUTS 48 /* 32 GENERICs + POS, PSIZE, FOG, etc. */
80#define INTEL_MAX_SHADER_SAMPLER_VIEWS 32
81#define INTEL_MAX_SHADER_RESOURCES 32
82#define INTEL_MAX_TEXTURE_LEVELS 16
83#define INTEL_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8
84#define INTEL_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2
85
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060086#define INTEL_MAX_DRAW_BUFFERS 8
87#define INTEL_MAX_CONST_BUFFERS (1 + 12)
88#define INTEL_MAX_SAMPLER_VIEWS 16
89#define INTEL_MAX_SAMPLERS 16
90#define INTEL_MAX_SO_BINDINGS 64
91#define INTEL_MAX_SO_BUFFERS 4
Courtney Goeltzenleuchterf21aaab2014-08-28 17:38:09 -060092#define INTEL_MAX_SO_OUTPUTS 64
93#define INTEL_MAX_VIEWPORTS 1 // TODO: Should this be 16 to match XGL_MAX_VIEWPORTS?
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060094
95#define INTEL_MAX_VS_SURFACES (INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS)
96#define INTEL_VS_CONST_SURFACE(i) (i)
97#define INTEL_VS_TEXTURE_SURFACE(i) (INTEL_MAX_CONST_BUFFERS + i)
98
99#define INTEL_MAX_GS_SURFACES (INTEL_MAX_SO_BINDINGS)
100#define INTEL_GS_SO_SURFACE(i) (i)
101
102#define INTEL_MAX_WM_SURFACES (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + INTEL_MAX_SAMPLER_VIEWS)
103#define INTEL_WM_DRAW_SURFACE(i) (i)
104#define INTEL_WM_CONST_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + i)
105#define INTEL_WM_TEXTURE_SURFACE(i) (INTEL_MAX_DRAW_BUFFERS + INTEL_MAX_CONST_BUFFERS + i)
106
107#define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX)
108#define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL)
109#define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION)
110#define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY)
111#define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT)
112#define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE)
113
Courtney Goeltzenleuchter650983f2014-08-28 17:38:54 -0600114struct intel_shader_cso {
115 uint32_t payload[5];
116};
117
118/**
119 * Stream output for vertex transform feedback.
120 */
121struct pipe_stream_output_info
122{
123 unsigned num_outputs;
124 /** stride for an entire vertex for each buffer in dwords */
125 unsigned stride[INTEL_MAX_SO_BUFFERS];
126
127 /**
128 * Array of stream outputs, in the order they are to be written in.
129 * Selected components are tightly packed into the output buffer.
130 */
131 struct {
132 unsigned register_index:8; /**< 0 to PIPE_MAX_SHADER_OUTPUTS */
133 unsigned start_component:2; /** 0 to 3 */
134 unsigned num_components:3; /** 1 to 4 */
135 unsigned output_buffer:3; /**< 0 to PIPE_MAX_SO_BUFFERS */
136 unsigned dst_offset:16; /**< offset into the buffer in dwords */
137 } output[INTEL_MAX_SO_OUTPUTS];
138};
139
140
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600141struct intel_pipe_shader {
Courtney Goeltzenleuchter650983f2014-08-28 17:38:54 -0600142 struct intel_shader_cso cso;
143
144 struct {
145 int semantic_names[INTEL_MAX_SHADER_INPUTS];
146 int semantic_indices[INTEL_MAX_SHADER_INPUTS];
147 int interp[INTEL_MAX_SHADER_INPUTS];
148 bool centroid[INTEL_MAX_SHADER_INPUTS];
149 int count;
150
151 int start_grf;
152 bool has_pos;
153 bool has_linear_interp;
154 int barycentric_interpolation_mode;
155 uint32_t const_interp_enable;
156 bool discard_adj;
157 } in;
158
159 struct {
160 int register_indices[INTEL_MAX_SHADER_OUTPUTS];
161 int semantic_names[INTEL_MAX_SHADER_OUTPUTS];
162 int semantic_indices[INTEL_MAX_SHADER_OUTPUTS];
163 int count;
164
165 bool has_pos;
166 } out;
167
168 bool has_kill;
169 bool dispatch_16;
170
171 bool stream_output;
172 int svbi_post_inc;
173 struct pipe_stream_output_info so_info;
174
175 /* for VS stream output / rasterizer discard */
176 int gs_offsets[3];
177 int gs_start_grf;
178
179 int num_samplers;
180
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600181 void *pCode;
182 uint32_t codeSize;
183};
184
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600185#define INTEL_PSO_CMD_ENTRIES 32
186
Courtney Goeltzenleuchteraa100cf2014-08-28 17:21:30 -0600187enum {
188 GEN6_WA_POST_SYNC_FLUSH = 1 << 0,
189 GEN6_WA_GEN7_VS_FLUSH = 1 << 1,
190 GEN7_WA_MULTISAMPLE_FLUSH = 1 << 2,
191};
192
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600193/**
194 * 3D pipeline.
195 */
196struct intel_pipeline {
197 struct intel_obj obj;
198
199 struct intel_dev *dev;
200
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600201 bool has_gen6_wa_pipe_control;
202
203 /* XGL IA_STATE */
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600204 XGL_PIPELINE_IA_STATE_CREATE_INFO ia_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600205 int prim_type;
206 bool primitive_restart;
207 uint32_t primitive_restart_index;
208
209 /* Index of provoking vertex for each prim type */
210 int provoking_vertex_tri;
211 int provoking_vertex_trifan;
212 int provoking_vertex_line;
213
214 // TODO: This should probably be Intel HW state, not XGL state.
215 /* Depth Buffer format */
216 XGL_FORMAT db_format;
217
218 XGL_PIPELINE_CB_STATE cb_state;
219
220 // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
221 bool depthClipEnable;
222 bool rasterizerDiscardEnable;
223 float pointSize;
224
225 XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600226
227 uint32_t active_shaders;
228 XGL_PIPELINE_SHADER vs;
229 XGL_PIPELINE_SHADER fs;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600230 struct intel_pipe_shader intel_vs;
231 struct intel_rmap *vs_rmap;
232 struct intel_pipe_shader intel_fs;
Chia-I Wued833872014-08-23 17:00:35 +0800233 struct intel_rmap *fs_rmap;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600234 struct intel_pipe_shader gs;
235 struct intel_pipe_shader tess_control;
236 struct intel_pipe_shader tess_eval;
237 struct intel_pipe_shader compute;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600238
239 int reduced_prim;
240 int so_num_vertices, so_max_vertices;
241
242 uint32_t SF_VIEWPORT;
243 uint32_t CLIP_VIEWPORT;
244 uint32_t SF_CLIP_VIEWPORT; /* GEN7+ */
245 uint32_t CC_VIEWPORT;
246
247 uint32_t COLOR_CALC_STATE;
248 uint32_t BLEND_STATE;
249 uint32_t DEPTH_STENCIL_STATE;
250
251 uint32_t SCISSOR_RECT;
252
253 struct {
254 uint32_t BINDING_TABLE_STATE;
255 int BINDING_TABLE_STATE_size;
256 uint32_t SURFACE_STATE[INTEL_MAX_VS_SURFACES];
257 uint32_t SAMPLER_STATE;
258 uint32_t SAMPLER_BORDER_COLOR_STATE[INTEL_MAX_SAMPLERS];
259 uint32_t PUSH_CONSTANT_BUFFER;
260 int PUSH_CONSTANT_BUFFER_size;
261 } vs_state;
262
263 struct {
264 uint32_t BINDING_TABLE_STATE;
265 int BINDING_TABLE_STATE_size;
266 uint32_t SURFACE_STATE[INTEL_MAX_GS_SURFACES];
267 bool active;
268 } gs_state;
269
270 struct {
271 uint32_t BINDING_TABLE_STATE;
272 int BINDING_TABLE_STATE_size;
273 uint32_t SURFACE_STATE[INTEL_MAX_WM_SURFACES];
274 uint32_t SAMPLER_STATE;
275 uint32_t SAMPLER_BORDER_COLOR_STATE[INTEL_MAX_SAMPLERS];
276 uint32_t PUSH_CONSTANT_BUFFER;
277 int PUSH_CONSTANT_BUFFER_size;
278 } wm_state;
Chia-I Wubb2d8ca2014-08-28 23:15:48 +0800279
Courtney Goeltzenleuchter68d9bef2014-08-28 17:35:03 -0600280 uint32_t pre_pso_wa_flags;
281 uint32_t post_pso_wa_flags;
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600282 uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
283 XGL_UINT cmd_len;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600284};
285
286static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
287{
288 return (struct intel_pipeline *) pipeline;
289}
290
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600291static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base)
292{
293 return (struct intel_pipeline *) base;
294}
295
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600296static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj)
297{
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600298 return intel_pipeline_from_base(&obj->base);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600299}
300
301XGL_RESULT XGLAPI intelCreateGraphicsPipeline(
302 XGL_DEVICE device,
303 const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo,
304 XGL_PIPELINE* pPipeline);
305
306XGL_RESULT XGLAPI intelCreateComputePipeline(
307 XGL_DEVICE device,
308 const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo,
309 XGL_PIPELINE* pPipeline);
310
311XGL_RESULT XGLAPI intelStorePipeline(
312 XGL_PIPELINE pipeline,
313 XGL_SIZE* pDataSize,
314 XGL_VOID* pData);
315
316XGL_RESULT XGLAPI intelLoadPipeline(
317 XGL_DEVICE device,
318 XGL_SIZE dataSize,
319 const XGL_VOID* pData,
320 XGL_PIPELINE* pPipeline);
321
322XGL_RESULT XGLAPI intelCreatePipelineDelta(
323 XGL_DEVICE device,
324 XGL_PIPELINE p1,
325 XGL_PIPELINE p2,
326 XGL_PIPELINE_DELTA* delta);
327#endif // PIPELINE_H