blob: 7c9ed3bb87ed9aabfc91fd2edd0325fb44c92d61 [file] [log] [blame]
Chia-I Wu5a323262014-08-11 10:31:53 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu5a323262014-08-11 10:31:53 +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 Wu5a323262014-08-11 10:31:53 +080026 */
27
28#ifndef VIEW_H
29#define VIEW_H
30
31#include "obj.h"
32#include "intel.h"
33
34struct intel_img;
35struct intel_mem;
36
37struct intel_null_view {
Chia-I Wuaabb3602014-08-19 14:18:23 +080038 /* this is not an intel_obj */
Chia-I Wu5a323262014-08-11 10:31:53 +080039
40 /* SURFACE_STATE */
41 uint32_t cmd[8];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060042 uint32_t cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080043};
44
Chia-I Wu714df452015-01-01 07:55:04 +080045struct intel_buf_view {
46 struct intel_obj obj;
Chia-I Wu5a323262014-08-11 10:31:53 +080047
Chia-I Wu714df452015-01-01 07:55:04 +080048 struct intel_buf *buf;
Chia-I Wu5a323262014-08-11 10:31:53 +080049
50 /* SURFACE_STATE */
51 uint32_t cmd[8];
Chia-I Wu34341ba2015-01-16 17:38:37 +080052 uint32_t fs_cmd[8];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060053 uint32_t cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080054};
55
56struct intel_img_view {
57 struct intel_obj obj;
58
59 struct intel_img *img;
60
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060061 float min_lod;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060062 VkChannelMapping shader_swizzles;
Chia-I Wu5a323262014-08-11 10:31:53 +080063
64 /* SURFACE_STATE */
65 uint32_t cmd[8];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060066 uint32_t cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080067};
68
69struct intel_rt_view {
70 struct intel_obj obj;
71
72 struct intel_img *img;
73
Chris Forbesfff9bf42015-06-15 15:26:19 +120074 uint32_t mipLevel;
75 uint32_t baseArraySlice;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060076 uint32_t array_size;
Mark Lobodzinski71fcc2d2015-01-27 13:24:03 -060077
Chia-I Wu5a323262014-08-11 10:31:53 +080078 /* SURFACE_STATE */
79 uint32_t cmd[8];
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060080 uint32_t cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080081};
82
83struct intel_ds_view {
84 struct intel_obj obj;
85
86 struct intel_img *img;
87
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060088 uint32_t array_size;
Mark Lobodzinski71fcc2d2015-01-27 13:24:03 -060089
Chia-I Wu5a323262014-08-11 10:31:53 +080090 /*
91 * 3DSTATE_DEPTH_BUFFER
92 * 3DSTATE_STENCIL_BUFFER
93 * 3DSTATE_HIER_DEPTH_BUFFER
94 */
95 uint32_t cmd[10];
Chia-I Wu3defd1f2015-02-18 12:21:22 -070096 bool has_stencil;
97 bool has_hiz;
Chia-I Wu5a323262014-08-11 10:31:53 +080098};
99
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600100static inline struct intel_buf_view *intel_buf_view(VkBufferView view)
Chia-I Wu714df452015-01-01 07:55:04 +0800101{
102 return (struct intel_buf_view *) view;
103}
104
105static inline struct intel_buf_view *intel_buf_view_from_obj(struct intel_obj *obj)
106{
107 return (struct intel_buf_view *) obj;
108}
109
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600110static inline struct intel_img_view *intel_img_view(VkImageView view)
Chia-I Wu5a323262014-08-11 10:31:53 +0800111{
112 return (struct intel_img_view *) view;
113}
114
115static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj)
116{
117 return (struct intel_img_view *) obj;
118}
119
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600120static inline struct intel_rt_view *intel_rt_view(VkColorAttachmentView view)
Chia-I Wu5a323262014-08-11 10:31:53 +0800121{
122 return (struct intel_rt_view *) view;
123}
124
125static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj)
126{
127 return (struct intel_rt_view *) obj;
128}
129
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600130static inline struct intel_ds_view *intel_ds_view(VkDepthStencilView view)
Chia-I Wu5a323262014-08-11 10:31:53 +0800131{
132 return (struct intel_ds_view *) view;
133}
134
135static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj)
136{
137 return (struct intel_ds_view *) obj;
138}
139
140void intel_null_view_init(struct intel_null_view *view,
141 struct intel_dev *dev);
142
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600143VkResult intel_buf_view_create(struct intel_dev *dev,
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600144 const VkBufferViewCreateInfo *info,
Chia-I Wu714df452015-01-01 07:55:04 +0800145 struct intel_buf_view **view_ret);
146
147void intel_buf_view_destroy(struct intel_buf_view *view);
Chia-I Wu5a323262014-08-11 10:31:53 +0800148
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600149VkResult intel_img_view_create(struct intel_dev *dev,
150 const VkImageViewCreateInfo *info,
Chia-I Wu5a323262014-08-11 10:31:53 +0800151 struct intel_img_view **view_ret);
152void intel_img_view_destroy(struct intel_img_view *view);
153
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600154VkResult intel_rt_view_create(struct intel_dev *dev,
155 const VkColorAttachmentViewCreateInfo *info,
Chia-I Wu5a323262014-08-11 10:31:53 +0800156 struct intel_rt_view **view_ret);
157void intel_rt_view_destroy(struct intel_rt_view *view);
158
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600159VkResult intel_ds_view_create(struct intel_dev *dev,
160 const VkDepthStencilViewCreateInfo *info,
Chia-I Wu5a323262014-08-11 10:31:53 +0800161 struct intel_ds_view **view_ret);
162void intel_ds_view_destroy(struct intel_ds_view *view);
163
Chia-I Wu5a323262014-08-11 10:31:53 +0800164#endif /* VIEW_H */