blob: 062e0ac4ae1202b60d480f63aed991de2bcd9b31 [file] [log] [blame]
Chia-I Wue54854a2014-08-05 10:23:50 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wue54854a2014-08-05 10:23:50 +08003 *
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 * Chia-I Wu <olv@lunarg.com>
Chia-I Wue54854a2014-08-05 10:23:50 +080026 */
27
28#ifndef DEV_H
29#define DEV_H
30
Chia-I Wue09b5362014-08-07 09:25:14 +080031#include "intel.h"
Chia-I Wue54854a2014-08-05 10:23:50 +080032#include "gpu.h"
Chia-I Wua2161db2014-08-15 16:34:34 +080033#include "obj.h"
Chia-I Wue54854a2014-08-05 10:23:50 +080034
Chia-I Wu8d24b3b2015-03-26 13:14:16 +080035struct intel_desc_region;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080036struct intel_pipeline_shader;
Chia-I Wue54854a2014-08-05 10:23:50 +080037struct intel_queue;
38struct intel_winsys;
39
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080040enum intel_dev_meta_shader {
41 /*
Chia-I Wu0c87f472014-11-25 14:37:30 +080042 * This expects an ivec2 to be pushed:
43 *
44 * .x is memory offset
45 * .y is fill value
46 *
47 * as well as GEN6_VFCOMP_STORE_VID.
48 */
49 INTEL_DEV_META_VS_FILL_MEM,
50
51 /*
52 * These expect an ivec2 to be pushed:
53 *
54 * .x is dst memory offset
55 * .y is src memory offset
56 *
57 * as well as GEN6_VFCOMP_STORE_VID.
58 */
59 INTEL_DEV_META_VS_COPY_MEM,
60 INTEL_DEV_META_VS_COPY_MEM_UNALIGNED,
61
62 /*
Chia-I Wu4d344e62014-12-20 21:06:04 +080063 * This expects an ivec4 to be pushed:
64 *
65 * .xy is added to fargment coord to form (u, v)
66 * .z is extent width
67 * .w is dst memory offset
68 *
69 * as well as GEN6_VFCOMP_STORE_VID.
70 */
71 INTEL_DEV_META_VS_COPY_R8_TO_MEM,
72 INTEL_DEV_META_VS_COPY_R16_TO_MEM,
73 INTEL_DEV_META_VS_COPY_R32_TO_MEM,
74 INTEL_DEV_META_VS_COPY_R32G32_TO_MEM,
75 INTEL_DEV_META_VS_COPY_R32G32B32A32_TO_MEM,
76
77 /*
Chia-I Wu9fe3ec42014-10-17 09:49:16 +080078 * These expect an ivec4 to be pushed:
79 *
80 * .xy is added to fragment coord to form (u, v)
81 * .z is ai
82 * .w is lod
83 */
84 INTEL_DEV_META_FS_COPY_MEM, /* ld_lz(u) */
85 INTEL_DEV_META_FS_COPY_1D, /* ld(u, lod) */
86 INTEL_DEV_META_FS_COPY_1D_ARRAY, /* ld(u, lod, ai) */
87 INTEL_DEV_META_FS_COPY_2D, /* ld(u, lod, v) */
88 INTEL_DEV_META_FS_COPY_2D_ARRAY, /* ld(u, lod, v, ai) */
89 INTEL_DEV_META_FS_COPY_2D_MS, /* ld_mcs() + ld2dms() */
90
91 /*
92 * These expect a second ivec4 to be pushed:
93 *
94 * .x is memory offset
95 * .y is extent width
96 *
97 * The second ivec4 is to convert linear fragment coord to (u, v).
98 */
99 INTEL_DEV_META_FS_COPY_1D_TO_MEM, /* ld(u, lod) */
100 INTEL_DEV_META_FS_COPY_1D_ARRAY_TO_MEM, /* ld(u, lod, ai) */
101 INTEL_DEV_META_FS_COPY_2D_TO_MEM, /* ld(u, lod, v) */
102 INTEL_DEV_META_FS_COPY_2D_ARRAY_TO_MEM, /* ld(u, lod, v, ai) */
103 INTEL_DEV_META_FS_COPY_2D_MS_TO_MEM, /* ld_mcs() + ld2dms() */
104
105 /*
106 * This expects an ivec4 to be pushed:
107 *
108 * .xy is added to fargment coord to form (u, v)
109 * .z is extent width
110 *
111 * .z is used to linearize (u, v).
112 */
113 INTEL_DEV_META_FS_COPY_MEM_TO_IMG, /* ld_lz(u) */
114
115 /*
116 * These expect the clear value to be pushed, and set fragment color or
117 * depth to the clear value.
118 */
119 INTEL_DEV_META_FS_CLEAR_COLOR,
120 INTEL_DEV_META_FS_CLEAR_DEPTH,
121
122 /*
123 * These expect an ivec4 to be pushed:
124 *
125 * .xy is added to fragment coord to form (u, v)
126 *
127 * All samples are fetched and averaged. The fragment color is set to the
128 * averaged value.
129 */
130 INTEL_DEV_META_FS_RESOLVE_2X,
131 INTEL_DEV_META_FS_RESOLVE_4X,
132 INTEL_DEV_META_FS_RESOLVE_8X,
133 INTEL_DEV_META_FS_RESOLVE_16X,
134
135 INTEL_DEV_META_SHADER_COUNT,
136};
137
Chia-I Wue54854a2014-08-05 10:23:50 +0800138struct intel_dev_dbg {
139 struct intel_base_dbg base;
Chia-I Wue54854a2014-08-05 10:23:50 +0800140};
141
142struct intel_dev {
143 struct intel_base base;
144
Courtney Goeltzenleuchter95b73722015-06-08 18:08:35 -0600145 bool phy_dev_exts[INTEL_PHY_DEV_EXT_COUNT];
Chia-I Wu1db76e02014-09-15 14:21:14 +0800146
Chia-I Wue54854a2014-08-05 10:23:50 +0800147 struct intel_gpu *gpu;
148 struct intel_winsys *winsys;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800149
Chia-I Wu0b784442014-08-25 22:54:16 +0800150 struct intel_bo *cmd_scratch_bo;
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800151 struct intel_pipeline_shader *cmd_meta_shaders[INTEL_DEV_META_SHADER_COUNT];
Chia-I Wu0b784442014-08-25 22:54:16 +0800152
Chia-I Wu8d24b3b2015-03-26 13:14:16 +0800153 struct intel_desc_region *desc_region;
Chia-I Wuf8385062015-01-04 16:27:24 +0800154
Chia-I Wu38d1ddf2015-03-02 10:51:39 -0700155 uint32_t sample_pattern_1x;
156 uint32_t sample_pattern_2x;
157 uint32_t sample_pattern_4x;
158 uint32_t sample_pattern_8x[2];
159 uint32_t sample_pattern_16x[4];
160
Chia-I Wue54854a2014-08-05 10:23:50 +0800161 struct intel_queue *queues[INTEL_GPU_ENGINE_COUNT];
162};
163
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600164static inline struct intel_dev *intel_dev(VkDevice dev)
Chia-I Wue54854a2014-08-05 10:23:50 +0800165{
166 return (struct intel_dev *) dev;
167}
168
169static inline struct intel_dev_dbg *intel_dev_dbg(struct intel_dev *dev)
170{
171 return (struct intel_dev_dbg *) dev->base.dbg;
172}
173
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600174VkResult intel_dev_create(struct intel_gpu *gpu,
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600175 const VkDeviceCreateInfo *info,
Chia-I Wue54854a2014-08-05 10:23:50 +0800176 struct intel_dev **dev_ret);
177void intel_dev_destroy(struct intel_dev *dev);
178
Chia-I Wu82d3d8b2014-08-09 13:07:44 +0800179void intel_dev_log(struct intel_dev *dev,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600180 VkFlags msg_flags,
Chia-I Wuaabb3602014-08-19 14:18:23 +0800181 struct intel_base *src_object,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600182 size_t location,
183 int32_t msg_code,
Chia-I Wu82d3d8b2014-08-09 13:07:44 +0800184 const char *format, ...);
185
Chia-I Wu9fe3ec42014-10-17 09:49:16 +0800186static inline const struct intel_pipeline_shader *intel_dev_get_meta_shader(const struct intel_dev *dev,
187 enum intel_dev_meta_shader id)
188{
189 assert(id < INTEL_DEV_META_SHADER_COUNT);
190 return dev->cmd_meta_shaders[id];
191}
192
Chia-I Wue54854a2014-08-05 10:23:50 +0800193#endif /* DEV_H */