blob: d7795350c8664af7e11b0fad8f69d1abc1413afb [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),
41 INTEL_SHADER_USE_COMPUTED_DEPTH = (1 << 3),
42 INTEL_SHADER_USE_DEPTH = (1 << 4),
43 INTEL_SHADER_USE_W = (1 << 5),
44};
45
Chia-I Wu20983762014-09-02 12:07:28 +080046#define INTEL_PIPELINE_RMAP_SLOT_RT ((XGL_UINT) -1)
47#define INTEL_PIPELINE_RMAP_SLOT_DYN ((XGL_UINT) -2)
48struct intel_pipeline_rmap_slot {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080049 /*
50 *
51 * When path_len is 0, the slot is unused.
52 * When path_len is 1, the slot uses descriptor "index".
53 * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index".
54 * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view.
55 * Otherwise, the slot uses "path" to find the descriptor.
56 */
57 XGL_UINT path_len;
58
59 union {
60 XGL_UINT index;
61 XGL_UINT *path;
62 } u;
63};
64
65/**
66 * Shader resource mapping.
67 */
Chia-I Wu20983762014-09-02 12:07:28 +080068struct intel_pipeline_rmap {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080069 /* this is not an intel_obj */
70
71 XGL_UINT rt_count;
72 XGL_UINT resource_count;
73 XGL_UINT uav_count;
74 XGL_UINT sampler_count;
Chia-I Wu1d125092014-10-08 08:49:38 +080075 XGL_UINT vb_count;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080076
77 /*
78 * rt_count slots +
79 * resource_count slots +
80 * uav_count slots +
Chia-I Wu1d125092014-10-08 08:49:38 +080081 * sampler_count slots +
82 * vb_count slots
Chia-I Wu1f7540b2014-08-22 13:56:18 +080083 */
Chia-I Wu20983762014-09-02 12:07:28 +080084 struct intel_pipeline_rmap_slot *slots;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080085 XGL_UINT slot_count;
86};
87
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060088#define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX)
89#define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL)
90#define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION)
91#define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY)
92#define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT)
93#define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE)
94
Chia-I Wuf2b6d722014-09-02 08:52:27 +080095struct intel_pipeline_shader {
96 /* this is not an intel_obj */
97
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -060098 void *pCode;
99 uint32_t codeSize;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600100
101 /*
102 * must grab everything we need from shader object as that
103 * can go away after the pipeline is created
104 */
105 XGL_FLAGS uses;
GregF2dc40212014-10-31 17:31:47 -0600106 uint32_t user_attributes_read;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600107
108 XGL_UINT in_count;
109 XGL_UINT out_count;
110
111 XGL_UINT sampler_count;
112 XGL_UINT surface_count;
113
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600114 XGL_UINT urb_grf_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600115
116 XGL_FLAGS barycentric_interps;
Chia-I Wu39026c92014-09-02 10:03:19 +0800117
Chia-I Wu20983762014-09-02 12:07:28 +0800118 struct intel_pipeline_rmap *rmap;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600119};
120
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800121/*
122 * On GEN6, there are
123 *
124 * - 3DSTATE_URB (3)
Chia-I Wu1d125092014-10-08 08:49:38 +0800125 * - 3DSTATE_VERTEX_ELEMENTS (1+2*34)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800126 *
127 * On GEN7, there are
128 *
129 * - 3DSTATE_URB_x (2*4)
130 * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5)
Chia-I Wu1d125092014-10-08 08:49:38 +0800131 * - 3DSTATE_VERTEX_ELEMENTS (1+2*34)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800132 * - 3DSTATE_HS (7)
133 * - 3DSTATE_TE (4)
134 * - 3DSTATE_DS (6)
135 */
Chia-I Wu1d125092014-10-08 08:49:38 +0800136#define INTEL_PSO_CMD_ENTRIES 128
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600137
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600138/**
139 * 3D pipeline.
140 */
141struct intel_pipeline {
142 struct intel_obj obj;
143
144 struct intel_dev *dev;
145
Chia-I Wu1d125092014-10-08 08:49:38 +0800146 XGL_VERTEX_INPUT_BINDING_DESCRIPTION vb[33];
147 XGL_UINT vb_count;
148
Chia-I Wube0a3d92014-09-02 13:20:59 +0800149 /* XGL_PIPELINE_IA_STATE_CREATE_INFO */
150 XGL_PRIMITIVE_TOPOLOGY topology;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600151 int prim_type;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800152 bool disable_vs_cache;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600153 bool primitive_restart;
154 uint32_t primitive_restart_index;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600155 /* Index of provoking vertex for each prim type */
156 int provoking_vertex_tri;
157 int provoking_vertex_trifan;
158 int provoking_vertex_line;
159
160 // TODO: This should probably be Intel HW state, not XGL state.
161 /* Depth Buffer format */
162 XGL_FORMAT db_format;
163
164 XGL_PIPELINE_CB_STATE cb_state;
165
166 // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
167 bool depthClipEnable;
168 bool rasterizerDiscardEnable;
169 float pointSize;
170
171 XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600172
173 uint32_t active_shaders;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800174 struct intel_pipeline_shader vs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800175 struct intel_pipeline_shader tcs;
176 struct intel_pipeline_shader tes;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800177 struct intel_pipeline_shader gs;
178 struct intel_pipeline_shader fs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800179 struct intel_pipeline_shader cs;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600180
Chia-I Wu8370b402014-08-29 12:28:37 +0800181 uint32_t wa_flags;
182
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600183 uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
184 XGL_UINT cmd_len;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600185};
186
187static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
188{
189 return (struct intel_pipeline *) pipeline;
190}
191
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600192static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base)
193{
194 return (struct intel_pipeline *) base;
195}
196
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600197static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj)
198{
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600199 return intel_pipeline_from_base(&obj->base);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600200}
201
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800202struct intel_pipeline_shader *intel_pipeline_shader_create_meta(struct intel_dev *dev,
203 enum intel_dev_meta_shader id);
204void intel_pipeline_shader_destroy(struct intel_pipeline_shader *sh);
205
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600206XGL_RESULT XGLAPI intelCreateGraphicsPipeline(
207 XGL_DEVICE device,
208 const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo,
209 XGL_PIPELINE* pPipeline);
210
211XGL_RESULT XGLAPI intelCreateComputePipeline(
212 XGL_DEVICE device,
213 const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo,
214 XGL_PIPELINE* pPipeline);
215
216XGL_RESULT XGLAPI intelStorePipeline(
217 XGL_PIPELINE pipeline,
218 XGL_SIZE* pDataSize,
219 XGL_VOID* pData);
220
221XGL_RESULT XGLAPI intelLoadPipeline(
222 XGL_DEVICE device,
223 XGL_SIZE dataSize,
224 const XGL_VOID* pData,
225 XGL_PIPELINE* pPipeline);
226
227XGL_RESULT XGLAPI intelCreatePipelineDelta(
228 XGL_DEVICE device,
229 XGL_PIPELINE p1,
230 XGL_PIPELINE p2,
231 XGL_PIPELINE_DELTA* delta);
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800232
233#endif /* PIPELINE_H */