blob: 07ed354b10cc55e044b64944f8448659f6647c2c [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 Wu20983762014-09-02 12:07:28 +080036#define INTEL_PIPELINE_RMAP_SLOT_RT ((XGL_UINT) -1)
37#define INTEL_PIPELINE_RMAP_SLOT_DYN ((XGL_UINT) -2)
38struct intel_pipeline_rmap_slot {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080039 /*
40 *
41 * When path_len is 0, the slot is unused.
42 * When path_len is 1, the slot uses descriptor "index".
43 * When path_len is INTEL_RMAP_SLOT_RT, the slot uses RT "index".
44 * When path_len is INTEL_RMAP_SLOT_DYN, the slot uses the dynamic view.
45 * Otherwise, the slot uses "path" to find the descriptor.
46 */
47 XGL_UINT path_len;
48
49 union {
50 XGL_UINT index;
51 XGL_UINT *path;
52 } u;
53};
54
55/**
56 * Shader resource mapping.
57 */
Chia-I Wu20983762014-09-02 12:07:28 +080058struct intel_pipeline_rmap {
Chia-I Wu1f7540b2014-08-22 13:56:18 +080059 /* this is not an intel_obj */
60
61 XGL_UINT rt_count;
62 XGL_UINT resource_count;
63 XGL_UINT uav_count;
64 XGL_UINT sampler_count;
65
66 /*
67 * rt_count slots +
68 * resource_count slots +
69 * uav_count slots +
70 * sampler_count slots
71 */
Chia-I Wu20983762014-09-02 12:07:28 +080072 struct intel_pipeline_rmap_slot *slots;
Chia-I Wu1f7540b2014-08-22 13:56:18 +080073 XGL_UINT slot_count;
74};
75
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -060076#define SHADER_VERTEX_FLAG (1 << XGL_SHADER_STAGE_VERTEX)
77#define SHADER_TESS_CONTROL_FLAG (1 << XGL_SHADER_STAGE_TESS_CONTROL)
78#define SHADER_TESS_EVAL_FLAG (1 << XGL_SHADER_STAGE_TESS_EVALUATION)
79#define SHADER_GEOMETRY_FLAG (1 << XGL_SHADER_STAGE_GEOMETRY)
80#define SHADER_FRAGMENT_FLAG (1 << XGL_SHADER_STAGE_FRAGMENT)
81#define SHADER_COMPUTE_FLAG (1 << XGL_SHADER_STAGE_COMPUTE)
82
Chia-I Wuf2b6d722014-09-02 08:52:27 +080083struct intel_pipeline_shader {
84 /* this is not an intel_obj */
85
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -060086 void *pCode;
87 uint32_t codeSize;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -060088
89 /*
90 * must grab everything we need from shader object as that
91 * can go away after the pipeline is created
92 */
93 XGL_FLAGS uses;
94
95 XGL_UINT in_count;
96 XGL_UINT out_count;
97
98 XGL_UINT sampler_count;
99 XGL_UINT surface_count;
100
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600101 XGL_UINT urb_grf_start;
Courtney Goeltzenleuchterc4ef6142014-08-29 16:25:30 -0600102
103 XGL_FLAGS barycentric_interps;
Chia-I Wu39026c92014-09-02 10:03:19 +0800104
Chia-I Wu20983762014-09-02 12:07:28 +0800105 struct intel_pipeline_rmap *rmap;
Chia-I Wuc3ddee62014-09-02 10:53:20 +0800106
107 void *pcb;
108 XGL_SIZE pcb_size;
Courtney Goeltzenleuchterd85c1d62014-08-27 14:04:53 -0600109};
110
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800111/*
112 * On GEN6, there are
113 *
114 * - 3DSTATE_URB (3)
Chia-I Wu4f3612b2014-08-29 15:40:39 +0800115 * - 3DSTATE_VERTEX_ELEMENTS (3)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800116 *
117 * On GEN7, there are
118 *
119 * - 3DSTATE_URB_x (2*4)
120 * - 3DSTATE_PUSH_CONSTANT_ALLOC_x (2*5)
Chia-I Wu4f3612b2014-08-29 15:40:39 +0800121 * - 3DSTATE_VERTEX_ELEMENTS (3)
Chia-I Wu1638c1c2014-08-29 14:01:16 +0800122 * - 3DSTATE_HS (7)
123 * - 3DSTATE_TE (4)
124 * - 3DSTATE_DS (6)
125 */
Courtney Goeltzenleuchterdee81a62014-08-28 18:05:24 -0600126#define INTEL_PSO_CMD_ENTRIES 64
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600127
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600128/**
129 * 3D pipeline.
130 */
131struct intel_pipeline {
132 struct intel_obj obj;
133
134 struct intel_dev *dev;
135
Chia-I Wube0a3d92014-09-02 13:20:59 +0800136 /* XGL_PIPELINE_IA_STATE_CREATE_INFO */
137 XGL_PRIMITIVE_TOPOLOGY topology;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600138 int prim_type;
Chia-I Wube0a3d92014-09-02 13:20:59 +0800139 bool disable_vs_cache;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600140 bool primitive_restart;
141 uint32_t primitive_restart_index;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600142 /* Index of provoking vertex for each prim type */
143 int provoking_vertex_tri;
144 int provoking_vertex_trifan;
145 int provoking_vertex_line;
146
147 // TODO: This should probably be Intel HW state, not XGL state.
148 /* Depth Buffer format */
149 XGL_FORMAT db_format;
150
151 XGL_PIPELINE_CB_STATE cb_state;
152
153 // XGL_PIPELINE_RS_STATE_CREATE_INFO rs_state;
154 bool depthClipEnable;
155 bool rasterizerDiscardEnable;
156 float pointSize;
157
158 XGL_PIPELINE_TESS_STATE_CREATE_INFO tess_state;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600159
160 uint32_t active_shaders;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800161 struct intel_pipeline_shader vs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800162 struct intel_pipeline_shader tcs;
163 struct intel_pipeline_shader tes;
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800164 struct intel_pipeline_shader gs;
165 struct intel_pipeline_shader fs;
Chia-I Wu95959fb2014-09-02 11:01:03 +0800166 struct intel_pipeline_shader cs;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600167
Chia-I Wu8370b402014-08-29 12:28:37 +0800168 uint32_t wa_flags;
169
Courtney Goeltzenleuchter814cd292014-08-28 13:16:27 -0600170 uint32_t cmds[INTEL_PSO_CMD_ENTRIES];
171 XGL_UINT cmd_len;
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600172};
173
174static inline struct intel_pipeline *intel_pipeline(XGL_PIPELINE pipeline)
175{
176 return (struct intel_pipeline *) pipeline;
177}
178
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600179static inline struct intel_pipeline *intel_pipeline_from_base(struct intel_base *base)
180{
181 return (struct intel_pipeline *) base;
182}
183
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600184static inline struct intel_pipeline *intel_pipeline_from_obj(struct intel_obj *obj)
185{
Courtney Goeltzenleuchter42509992014-08-21 17:33:46 -0600186 return intel_pipeline_from_base(&obj->base);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600187}
188
189XGL_RESULT XGLAPI intelCreateGraphicsPipeline(
190 XGL_DEVICE device,
191 const XGL_GRAPHICS_PIPELINE_CREATE_INFO* pCreateInfo,
192 XGL_PIPELINE* pPipeline);
193
194XGL_RESULT XGLAPI intelCreateComputePipeline(
195 XGL_DEVICE device,
196 const XGL_COMPUTE_PIPELINE_CREATE_INFO* pCreateInfo,
197 XGL_PIPELINE* pPipeline);
198
199XGL_RESULT XGLAPI intelStorePipeline(
200 XGL_PIPELINE pipeline,
201 XGL_SIZE* pDataSize,
202 XGL_VOID* pData);
203
204XGL_RESULT XGLAPI intelLoadPipeline(
205 XGL_DEVICE device,
206 XGL_SIZE dataSize,
207 const XGL_VOID* pData,
208 XGL_PIPELINE* pPipeline);
209
210XGL_RESULT XGLAPI intelCreatePipelineDelta(
211 XGL_DEVICE device,
212 XGL_PIPELINE p1,
213 XGL_PIPELINE p2,
214 XGL_PIPELINE_DELTA* delta);
Chia-I Wuf2b6d722014-09-02 08:52:27 +0800215
216#endif /* PIPELINE_H */