blob: abd9dd43cf7a0d0991ce4c96e98786aa51821c1c [file] [log] [blame]
Chia-I Wu5a323262014-08-11 10:31:53 +08001/*
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 * 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];
Chia-I Wucd83cf12014-08-23 17:26:08 +080042 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080043};
44
45struct intel_mem_view {
Chia-I Wuaabb3602014-08-19 14:18:23 +080046 /* this is not an intel_obj */
Chia-I Wu5a323262014-08-11 10:31:53 +080047
48 struct intel_mem *mem;
49
50 /* SURFACE_STATE */
51 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080052 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080053};
54
55struct intel_img_view {
56 struct intel_obj obj;
57
58 struct intel_img *img;
59
60 XGL_CHANNEL_MAPPING swizzles;
61 XGL_FLOAT min_lod;
62
63 /* SURFACE_STATE */
64 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080065 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080066};
67
68struct intel_rt_view {
69 struct intel_obj obj;
70
71 struct intel_img *img;
72
73 /* SURFACE_STATE */
74 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080075 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080076};
77
78struct intel_ds_view {
79 struct intel_obj obj;
80
81 struct intel_img *img;
82
83 /*
84 * 3DSTATE_DEPTH_BUFFER
85 * 3DSTATE_STENCIL_BUFFER
86 * 3DSTATE_HIER_DEPTH_BUFFER
87 */
88 uint32_t cmd[10];
89};
90
91static inline struct intel_img_view *intel_img_view(XGL_IMAGE_VIEW view)
92{
93 return (struct intel_img_view *) view;
94}
95
96static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj)
97{
98 return (struct intel_img_view *) obj;
99}
100
101static inline struct intel_rt_view *intel_rt_view(XGL_COLOR_ATTACHMENT_VIEW view)
102{
103 return (struct intel_rt_view *) view;
104}
105
106static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj)
107{
108 return (struct intel_rt_view *) obj;
109}
110
111static inline struct intel_ds_view *intel_ds_view(XGL_DEPTH_STENCIL_VIEW view)
112{
113 return (struct intel_ds_view *) view;
114}
115
116static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj)
117{
118 return (struct intel_ds_view *) obj;
119}
120
121void intel_null_view_init(struct intel_null_view *view,
122 struct intel_dev *dev);
123
124void intel_mem_view_init(struct intel_mem_view *view,
125 struct intel_dev *dev,
126 const XGL_MEMORY_VIEW_ATTACH_INFO *info);
127
128XGL_RESULT intel_img_view_create(struct intel_dev *dev,
129 const XGL_IMAGE_VIEW_CREATE_INFO *info,
130 struct intel_img_view **view_ret);
131void intel_img_view_destroy(struct intel_img_view *view);
132
133XGL_RESULT intel_rt_view_create(struct intel_dev *dev,
134 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO *info,
135 struct intel_rt_view **view_ret);
136void intel_rt_view_destroy(struct intel_rt_view *view);
137
138XGL_RESULT intel_ds_view_create(struct intel_dev *dev,
139 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO *info,
140 struct intel_ds_view **view_ret);
141void intel_ds_view_destroy(struct intel_ds_view *view);
142
143XGL_RESULT XGLAPI intelCreateImageView(
144 XGL_DEVICE device,
145 const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo,
146 XGL_IMAGE_VIEW* pView);
147
148XGL_RESULT XGLAPI intelCreateColorAttachmentView(
149 XGL_DEVICE device,
150 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo,
151 XGL_COLOR_ATTACHMENT_VIEW* pView);
152
153XGL_RESULT XGLAPI intelCreateDepthStencilView(
154 XGL_DEVICE device,
155 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo,
156 XGL_DEPTH_STENCIL_VIEW* pView);
157
158#endif /* VIEW_H */