blob: 04a7693f39519e210ec2a75d8bbda70b73975a02 [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
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;
49 XGL_BUFFER_VIEW_CREATE_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
Chia-I Wu714df452015-01-01 07:55:04 +080092static inline struct intel_buf_view *intel_buf_view(XGL_BUFFER_VIEW view)
93{
94 return (struct intel_buf_view *) view;
95}
96
97static inline struct intel_buf_view *intel_buf_view_from_obj(struct intel_obj *obj)
98{
99 return (struct intel_buf_view *) obj;
100}
101
Chia-I Wu5a323262014-08-11 10:31:53 +0800102static inline struct intel_img_view *intel_img_view(XGL_IMAGE_VIEW view)
103{
104 return (struct intel_img_view *) view;
105}
106
107static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj)
108{
109 return (struct intel_img_view *) obj;
110}
111
112static inline struct intel_rt_view *intel_rt_view(XGL_COLOR_ATTACHMENT_VIEW view)
113{
114 return (struct intel_rt_view *) view;
115}
116
117static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj)
118{
119 return (struct intel_rt_view *) obj;
120}
121
122static inline struct intel_ds_view *intel_ds_view(XGL_DEPTH_STENCIL_VIEW view)
123{
124 return (struct intel_ds_view *) view;
125}
126
127static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj)
128{
129 return (struct intel_ds_view *) obj;
130}
131
132void intel_null_view_init(struct intel_null_view *view,
133 struct intel_dev *dev);
134
Chia-I Wu714df452015-01-01 07:55:04 +0800135XGL_RESULT intel_buf_view_create(struct intel_dev *dev,
136 const XGL_BUFFER_VIEW_CREATE_INFO *info,
137 struct intel_buf_view **view_ret);
138
139void intel_buf_view_destroy(struct intel_buf_view *view);
Chia-I Wu5a323262014-08-11 10:31:53 +0800140
141XGL_RESULT intel_img_view_create(struct intel_dev *dev,
142 const XGL_IMAGE_VIEW_CREATE_INFO *info,
143 struct intel_img_view **view_ret);
144void intel_img_view_destroy(struct intel_img_view *view);
145
146XGL_RESULT intel_rt_view_create(struct intel_dev *dev,
147 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO *info,
148 struct intel_rt_view **view_ret);
149void intel_rt_view_destroy(struct intel_rt_view *view);
150
151XGL_RESULT intel_ds_view_create(struct intel_dev *dev,
152 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO *info,
153 struct intel_ds_view **view_ret);
154void intel_ds_view_destroy(struct intel_ds_view *view);
155
Chia-I Wu5a323262014-08-11 10:31:53 +0800156#endif /* VIEW_H */