blob: 25542e868880bf07e29e89caf3fb78f34c9c4fac [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"
34#include "dev.h"
35
Chia-I Wua4d1b392014-10-10 13:57:29 +080036enum intel_pipeline_shader_use {
37 INTEL_SHADER_USE_VID = (1 << 0),
38 INTEL_SHADER_USE_IID = (1 << 1),
39
40 INTEL_SHADER_USE_KILL = (1 << 2),
Cody Northrope238deb2015-01-26 14:41:36 -070041 INTEL_SHADER_USE_DEPTH = (1 << 3),
42 INTEL_SHADER_USE_W = (1 << 4),
43};
44
45/* This order must match Pixel Shader Computed Depth Mode in 3DSTATE_WM */
46enum intel_computed_depth_mode {
47 INTEL_COMPUTED_DEPTH_MODE_NONE,
48 INTEL_COMPUTED_DEPTH_MODE_ON,
49 INTEL_COMPUTED_DEPTH_MODE_ON_GE,
50 INTEL_COMPUTED_DEPTH_MODE_ON_LE
Chia-I Wua4d1b392014-10-10 13:57:29 +080051};
52
Chia-I Wu20983762014-09-02 12:07:28 +080053#define INTEL_PIPELINE_RMAP_SLOT_RT ((XGL_UINT) -1)
54#define INTEL_PIPELINE_RMAP_SLOT_DYN ((XGL_UINT) -2)
55struct intel_pipeline_rmap_slot {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080056 /*
57 *
58 * When path_len is 0, the slot is unused.
59 * When path_len is 1, the slot uses descriptor "index".
60 * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index".
61 * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view.
62 * Otherwise, the slot uses "path" to find the descriptor.
63 */
64 XGL_UINT path_len;
65
66 union {
67 XGL_UINT index;
68 XGL_UINT *path;
69 } u;
70};
71
72/**
73 * Shader resource mapping.
74 */
Chia-I Wu20983762014-09-02 12:07:28 +080075struct intel_pipeline_rmap {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080076 /* this is not an intel_obj */
77
78 XGL_UINT rt_count;
Cody Northrop40316a32014-12-09 19:08:33 -070079 XGL_UINT texture_resource_count;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080080 XGL_UINT resource_count;
81 XGL_UINT uav_count;
82 XGL_UINT sampler_count;
83
84 /*
85 * rt_count slots +
86 * resource_count slots +
87 * uav_count slots +
Chia-I Wu3b04af52014-11-08 10:48:20 +080088 * sampler_count slots
Chia-I Wu1f7540b2014-08-22 13:56:18 +080089 */
Chia-I Wu20983762014-09-02 12:07:28 +080090 struct intel_pipeline_rmap_slot *slots;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080091 XGL_UINT slot_count;
92};
93
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060094#define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX)
95#define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL)
96#define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION)
97#define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY)
98#define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT)
99#define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE)
100
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800101struct intel_pipeline_shader {
102 /* this is not an intel_obj */
103
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600104 void *pCode;
105 uint32_t codeSize;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600106
107 /*
108 * must grab everything we need from shader object as that
109 * can go away after the pipeline is created
110 */
111 XGL_FLAGS uses;
GregF8cd81832014-11-18 18:01:01 -0700112 uint64_t inputs_read;
113 uint64_t outputs_written;
114 XGL_UINT outputs_offset;
Cody Northropd75c13e2015-01-02 14:07:20 -0700115 XGL_UINT generic_input_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600116
GregFfd4c1f92014-11-07 15:32:52 -0700117 XGL_BOOL enable_user_clip;
GregF8cd81832014-11-18 18:01:01 -0700118 XGL_BOOL reads_user_clip;
GregFfd4c1f92014-11-07 15:32:52 -0700119
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600120 XGL_UINT in_count;
121 XGL_UINT out_count;
122
123 XGL_UINT sampler_count;
124 XGL_UINT surface_count;
125
Cody Northrop37c47052014-12-11 09:58:50 -0700126 XGL_UINT ubo_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600127 XGL_UINT urb_grf_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600128
129 XGL_FLAGS barycentric_interps;
Chia-I Wu39026c92014-09-02 10:03:19 +0800130
Chia-I Wub1024732014-12-19 13:00:29 +0800131 XGL_GPU_SIZE per_thread_scratch_size;
132
Cody Northrope238deb2015-01-26 14:41:36 -0700133 enum intel_computed_depth_mode computed_depth_mode;
134
Chia-I Wu20983762014-09-02 12:07:28 +0800135 struct intel_pipeline_rmap *rmap;
Chia-I Wu5667d6f2014-12-11 22:37:37 +0800136
137 /* these are set up by the driver */
Chia-I Wu3f4bd102014-12-19 13:14:42 +0800138 XGL_UINT max_threads;
Chia-I Wub1024732014-12-19 13:00:29 +0800139 XGL_GPU_SIZE scratch_offset;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600140};
141
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800142/*
143 * On GEN6, there are
144 *
145 * - 3DSTATE_URB (3)
Chia-I Wu24693712014-11-08 11:54:47 +0800146 * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800147 *
148 * On GEN7, there are
149 *
150 * - 3DSTATE_URB_x (2*4)
151 * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5)
Chia-I Wu24693712014-11-08 11:54:47 +0800152 * - 3DSTATE_VERTEX_ELEMENTS (1+2*INTEL_MAX_VERTEX_ELEMENT_COUNT)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800153 * - 3DSTATE_HS (7)
154 * - 3DSTATE_TE (4)
155 * - 3DSTATE_DS (6)
156 */
Chia-I Wu1d125092014-10-08 08:49:38 +0800157#define INTEL_PSO_CMD_ENTRIES 128
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600158
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600159/**
160 * 3D pipeline.
161 */
162struct intel_pipeline {
163 struct intel_obj obj;
164
165 struct intel_dev *dev;
166
Chia-I Wu24693712014-11-08 11:54:47 +0800167 XGL_VERTEX_INPUT_BINDING_DESCRIPTION vb[INTEL_MAX_VERTEX_BINDING_COUNT];
Chia-I Wu1d125092014-10-08 08:49:38 +0800168 XGL_UINT vb_count;
169
Chia-I Wube0a3d92014-09-02 13:20:59 +0800170 /* XGL_PIPELINE_IA_STATE_CREATE_INFO */
171 XGL_PRIMITIVE_TOPOLOGY topology;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600172 int prim_type;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800173 bool disable_vs_cache;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600174 bool primitive_restart;
175 uint32_t primitive_restart_index;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600176 /* Index of provoking vertex for each prim type */
177 int provoking_vertex_tri;
178 int provoking_vertex_trifan;
179 int provoking_vertex_line;
180
181 // TODO: This should probably be Intel HW state, not XGL state.
182 /* Depth Buffer format */
183 XGL_FORMAT db_format;
184
185 XGL_PIPELINE_CB_STATE cb_state;
186
187 // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
188 bool depthClipEnable;
189 bool rasterizerDiscardEnable;
190 float pointSize;
191
192 XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600193
194 uint32_t active_shaders;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800195 struct intel_pipeline_shader vs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800196 struct intel_pipeline_shader tcs;
197 struct intel_pipeline_shader tes;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800198 struct intel_pipeline_shader gs;
199 struct intel_pipeline_shader fs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800200 struct intel_pipeline_shader cs;
Chia-I Wub1024732014-12-19 13:00:29 +0800201 XGL_GPU_SIZE scratch_size;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600202
Chia-I Wu8370b402014-08-29 12:28:37 +0800203 uint32_t wa_flags;
204
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600205 uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
206 XGL_UINT cmd_len;
GregF8cd81832014-11-18 18:01:01 -0700207 XGL_UINT cmd_sbe_body_offset;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600208};
209
210static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
211{
212 return (struct intel_pipeline *) pipeline;
213}
214
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600215static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base)
216{
217 return (struct intel_pipeline *) base;
218}
219
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600220static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj)
221{
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600222 return intel_pipeline_from_base(&obj->base);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600223}
224
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800225struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
226 enum intel_dev_meta_shader id);
227void intel_pipeline_shader_destroy(struct intel_pipeline_shader *sh);
228
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800229#endif /* PIPELINE_H */