blob: e5ec124889f6583cc092f5395732ff7738024120 [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;
Cody Northrop7c76f302014-12-18 11:52:58 -070049 XGL_MEMORY_VIEW_ATTACH_INFO info;
Chia-I Wu5a323262014-08-11 10:31:53 +080050
51 /* SURFACE_STATE */
52 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080053 XGL_UINT 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
Chia-I Wu5a323262014-08-11 10:31:53 +080061 XGL_FLOAT min_lod;
Chia-I Wuf57758c2014-12-02 14:15:50 +080062 XGL_CHANNEL_MAPPING shader_swizzles;
Chia-I Wu5a323262014-08-11 10:31:53 +080063
64 /* SURFACE_STATE */
65 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080066 XGL_UINT 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
74 /* SURFACE_STATE */
75 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080076 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080077};
78
79struct intel_ds_view {
80 struct intel_obj obj;
81
82 struct intel_img *img;
83
84 /*
85 * 3DSTATE_DEPTH_BUFFER
86 * 3DSTATE_STENCIL_BUFFER
87 * 3DSTATE_HIER_DEPTH_BUFFER
88 */
89 uint32_t cmd[10];
90};
91
92static inline struct intel_img_view *intel_img_view(XGL_IMAGE_VIEW view)
93{
94 return (struct intel_img_view *) view;
95}
96
97static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj)
98{
99 return (struct intel_img_view *) obj;
100}
101
102static inline struct intel_rt_view *intel_rt_view(XGL_COLOR_ATTACHMENT_VIEW view)
103{
104 return (struct intel_rt_view *) view;
105}
106
107static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj)
108{
109 return (struct intel_rt_view *) obj;
110}
111
112static inline struct intel_ds_view *intel_ds_view(XGL_DEPTH_STENCIL_VIEW view)
113{
114 return (struct intel_ds_view *) view;
115}
116
117static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj)
118{
119 return (struct intel_ds_view *) obj;
120}
121
122void intel_null_view_init(struct intel_null_view *view,
123 struct intel_dev *dev);
124
125void intel_mem_view_init(struct intel_mem_view *view,
126 struct intel_dev *dev,
127 const XGL_MEMORY_VIEW_ATTACH_INFO *info);
128
129XGL_RESULT intel_img_view_create(struct intel_dev *dev,
130 const XGL_IMAGE_VIEW_CREATE_INFO *info,
131 struct intel_img_view **view_ret);
132void intel_img_view_destroy(struct intel_img_view *view);
133
134XGL_RESULT intel_rt_view_create(struct intel_dev *dev,
135 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO *info,
136 struct intel_rt_view **view_ret);
137void intel_rt_view_destroy(struct intel_rt_view *view);
138
139XGL_RESULT intel_ds_view_create(struct intel_dev *dev,
140 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO *info,
141 struct intel_ds_view **view_ret);
142void intel_ds_view_destroy(struct intel_ds_view *view);
143
144XGL_RESULT XGLAPI intelCreateImageView(
145 XGL_DEVICE device,
146 const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo,
147 XGL_IMAGE_VIEW* pView);
148
149XGL_RESULT XGLAPI intelCreateColorAttachmentView(
150 XGL_DEVICE device,
151 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo,
152 XGL_COLOR_ATTACHMENT_VIEW* pView);
153
154XGL_RESULT XGLAPI intelCreateDepthStencilView(
155 XGL_DEVICE device,
156 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo,
157 XGL_DEPTH_STENCIL_VIEW* pView);
158
159#endif /* VIEW_H */