blob: 3cae425f5f5d35d31a8400d40ea3e07684a3c60e [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.
Chia-I Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Courtney Goeltzenleuchter <courtney@lunarg.com>
26 * Chia-I Wu <olv@lunarg.com>
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060027 */
28
29#ifndef PIPELINE_H
30#define PIPELINE_H
31
32#include "intel.h"
33#include "obj.h"
Chia-I Wuf8385062015-01-04 16:27:24 +080034#include "desc.h"
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060035#include "dev.h"
36
Chia-I Wua4d1b392014-10-10 13:57:29 +080037enum intel_pipeline_shader_use {
38 INTEL_SHADER_USE_VID = (1 << 0),
39 INTEL_SHADER_USE_IID = (1 << 1),
40
41 INTEL_SHADER_USE_KILL = (1 << 2),
Cody Northrope238deb2015-01-26 14:41:36 -070042 INTEL_SHADER_USE_DEPTH = (1 << 3),
43 INTEL_SHADER_USE_W = (1 << 4),
44};
45
46/* This order must match Pixel Shader Computed Depth Mode in 3DSTATE_WM */
47enum intel_computed_depth_mode {
48 INTEL_COMPUTED_DEPTH_MODE_NONE,
49 INTEL_COMPUTED_DEPTH_MODE_ON,
50 INTEL_COMPUTED_DEPTH_MODE_ON_GE,
51 INTEL_COMPUTED_DEPTH_MODE_ON_LE
Chia-I Wua4d1b392014-10-10 13:57:29 +080052};
53
Chia-I Wuf8385062015-01-04 16:27:24 +080054enum intel_pipeline_rmap_slot_type {
55 INTEL_PIPELINE_RMAP_UNUSED,
56 INTEL_PIPELINE_RMAP_RT,
57 INTEL_PIPELINE_RMAP_SURFACE,
58 INTEL_PIPELINE_RMAP_SAMPLER,
59};
60
Chia-I Wu20983762014-09-02 12:07:28 +080061struct intel_pipeline_rmap_slot {
Chia-I Wuf8385062015-01-04 16:27:24 +080062 enum intel_pipeline_rmap_slot_type type;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080063
64 union {
Chia-I Wuf8385062015-01-04 16:27:24 +080065 uint32_t rt;
66 struct {
67 struct intel_desc_offset offset;
68 int dynamic_offset_index;
69 } surface;
70 struct intel_desc_offset sampler;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080071 } u;
72};
73
74/**
75 * Shader resource mapping.
76 */
Chia-I Wu20983762014-09-02 12:07:28 +080077struct intel_pipeline_rmap {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080078 /* this is not an intel_obj */
79
80 XGL_UINT rt_count;
Cody Northrop40316a32014-12-09 19:08:33 -070081 XGL_UINT texture_resource_count;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080082 XGL_UINT resource_count;
83 XGL_UINT uav_count;
84 XGL_UINT sampler_count;
85
86 /*
87 * rt_count slots +
88 * resource_count slots +
89 * uav_count slots +
Chia-I Wu3b04af52014-11-08 10:48:20 +080090 * sampler_count slots
Chia-I Wu1f7540b2014-08-22 13:56:18 +080091 */
Chia-I Wu20983762014-09-02 12:07:28 +080092 struct intel_pipeline_rmap_slot *slots;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080093 XGL_UINT slot_count;
94};
95
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060096#define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX)
97#define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL)
98#define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION)
99#define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY)
100#define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT)
101#define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE)
102
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800103struct intel_pipeline_shader {
104 /* this is not an intel_obj */
105
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600106 void *pCode;
107 uint32_t codeSize;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600108
109 /*
110 * must grab everything we need from shader object as that
111 * can go away after the pipeline is created
112 */
113 XGL_FLAGS uses;
GregF8cd81832014-11-18 18:01:01 -0700114 uint64_t inputs_read;
115 uint64_t outputs_written;
116 XGL_UINT outputs_offset;
Cody Northropd75c13e2015-01-02 14:07:20 -0700117 XGL_UINT generic_input_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600118
GregFfd4c1f92014-11-07 15:32:52 -0700119 XGL_BOOL enable_user_clip;
GregF8cd81832014-11-18 18:01:01 -0700120 XGL_BOOL reads_user_clip;
GregFfd4c1f92014-11-07 15:32:52 -0700121
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600122 XGL_UINT in_count;
123 XGL_UINT out_count;
124
125 XGL_UINT sampler_count;
126 XGL_UINT surface_count;
127
Cody Northrop37c47052014-12-11 09:58:50 -0700128 XGL_UINT ubo_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600129 XGL_UINT urb_grf_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600130
131 XGL_FLAGS barycentric_interps;
Chia-I Wu39026c92014-09-02 10:03:19 +0800132
Chia-I Wub1024732014-12-19 13:00:29 +0800133 XGL_GPU_SIZE per_thread_scratch_size;
134
Cody Northrope238deb2015-01-26 14:41:36 -0700135 enum intel_computed_depth_mode computed_depth_mode;
136
Chia-I Wu20983762014-09-02 12:07:28 +0800137 struct intel_pipeline_rmap *rmap;
Chia-I Wu5667d6f2014-12-11 22:37:37 +0800138
139 /* these are set up by the driver */
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800140 XGL_UINT max_threads;
Chia-I Wub1024732014-12-19 13:00:29 +0800141 XGL_GPU_SIZE scratch_offset;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600142};
143
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800144/*
145 * On GEN6, there are
146 *
147 * - 3DSTATE_URB (3)
Chia-I Wu24693712014-11-08 11:54:47 +0800148 * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
Tony Barbourfa6cac72015-01-16 14:27:35 -0700149 * - 3DSTATE_MULTISAMPLE (3)
150 * - 3DSTATE_SAMPLE_MASK (2)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800151 *
152 * On GEN7, there are
153 *
154 * - 3DSTATE_URB_x (2*4)
155 * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5)
Chia-I Wu24693712014-11-08 11:54:47 +0800156 * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
Tony Barbourfa6cac72015-01-16 14:27:35 -0700157 * - 3DSTATE_SBE (14)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800158 * - 3DSTATE_HS (7)
159 * - 3DSTATE_TE (4)
160 * - 3DSTATE_DS (6)
Tony Barbourfa6cac72015-01-16 14:27:35 -0700161 * - 3DSTATE_MULTISAMPLE (4)
162 * - 3DSTATE_SAMPLE_MASK (2)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800163 */
Chia-I Wu1d125092014-10-08 08:49:38 +0800164#define INTEL_PSO_CMD_ENTRIES 128
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600165
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600166/**
167 * 3D pipeline.
168 */
169struct intel_pipeline {
170 struct intel_obj obj;
171
172 struct intel_dev *dev;
173
Chia-I Wu24693712014-11-08 11:54:47 +0800174 XGL_VERTEX_INPUT_BINDING_DESCRIPTION vb[INTEL_MAX_VERTEX_BINDING_COUNT];
Chia-I Wu1d125092014-10-08 08:49:38 +0800175 XGL_UINT vb_count;
176
Chia-I Wube0a3d92014-09-02 13:20:59 +0800177 /* XGL_PIPELINE_IA_STATE_CREATE_INFO */
178 XGL_PRIMITIVE_TOPOLOGY topology;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600179 int prim_type;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800180 bool disable_vs_cache;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600181 bool primitive_restart;
182 uint32_t primitive_restart_index;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600183 /* Index of provoking vertex for each prim type */
184 int provoking_vertex_tri;
185 int provoking_vertex_trifan;
186 int provoking_vertex_line;
187
188 // TODO: This should probably be Intel HW state, not XGL state.
189 /* Depth Buffer format */
190 XGL_FORMAT db_format;
191
Tony Barbourfa6cac72015-01-16 14:27:35 -0700192 XGL_PIPELINE_CB_STATE_CREATE_INFO cb_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600193
194 // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
195 bool depthClipEnable;
196 bool rasterizerDiscardEnable;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700197 bool scissor_enable;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600198
199 XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600200
201 uint32_t active_shaders;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800202 struct intel_pipeline_shader vs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800203 struct intel_pipeline_shader tcs;
204 struct intel_pipeline_shader tes;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800205 struct intel_pipeline_shader gs;
206 struct intel_pipeline_shader fs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800207 struct intel_pipeline_shader cs;
Chia-I Wub1024732014-12-19 13:00:29 +0800208 XGL_GPU_SIZE scratch_size;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600209
Chia-I Wu8370b402014-08-29 12:28:37 +0800210 uint32_t wa_flags;
211
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600212 uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
213 XGL_UINT cmd_len;
GregF8cd81832014-11-18 18:01:01 -0700214 XGL_UINT cmd_sbe_body_offset;
Tony Barbourfa6cac72015-01-16 14:27:35 -0700215
216 /* The following are only partial HW commands that will need
217 * more processing before sending to the HW
218 */
219 // XGL_PIPELINE_DS_STATE_CREATE_INFO ds_state
220 bool stencilTestEnable;
221 uint32_t cmd_depth_stencil;
222 uint32_t cmd_depth_test;
223
224 uint32_t cmd_sf_fill;
225 uint32_t cmd_clip_cull;
226 uint32_t cmd_sf_cull;
227 uint32_t cmd_cb[2 * INTEL_MAX_RENDER_TARGETS];
228 uint32_t sample_count;
229 uint32_t cmd_sample_mask;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600230};
231
232static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
233{
234 return (struct intel_pipeline *) pipeline;
235}
236
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600237static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base)
238{
239 return (struct intel_pipeline *) base;
240}
241
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600242static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj)
243{
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600244 return intel_pipeline_from_base(&obj->base);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600245}
246
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800247struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
248 enum intel_dev_meta_shader id);
249void intel_pipeline_shader_destroy(struct intel_pipeline_shader *sh);
250
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800251#endif /* PIPELINE_H */