blob: e19935b0501ef0142b6387d742cce5f6f6c520b2 [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.
23 */
24
25#ifndef VIEW_H
26#define VIEW_H
27
28#include "obj.h"
29#include "intel.h"
30
31struct intel_img;
32struct intel_mem;
33
34struct intel_null_view {
Chia-I Wuaabb3602014-08-19 14:18:23 +080035 /* this is not an intel_obj */
Chia-I Wu5a323262014-08-11 10:31:53 +080036
37 /* SURFACE_STATE */
38 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080039 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080040};
41
42struct intel_mem_view {
Chia-I Wuaabb3602014-08-19 14:18:23 +080043 /* this is not an intel_obj */
Chia-I Wu5a323262014-08-11 10:31:53 +080044
45 struct intel_mem *mem;
46
47 /* SURFACE_STATE */
48 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080049 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080050};
51
52struct intel_img_view {
53 struct intel_obj obj;
54
55 struct intel_img *img;
56
57 XGL_CHANNEL_MAPPING swizzles;
58 XGL_FLOAT min_lod;
59
60 /* SURFACE_STATE */
61 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080062 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080063};
64
65struct intel_rt_view {
66 struct intel_obj obj;
67
68 struct intel_img *img;
69
70 /* SURFACE_STATE */
71 uint32_t cmd[8];
Chia-I Wucd83cf12014-08-23 17:26:08 +080072 XGL_UINT cmd_len;
Chia-I Wu5a323262014-08-11 10:31:53 +080073};
74
75struct intel_ds_view {
76 struct intel_obj obj;
77
78 struct intel_img *img;
79
80 /*
81 * 3DSTATE_DEPTH_BUFFER
82 * 3DSTATE_STENCIL_BUFFER
83 * 3DSTATE_HIER_DEPTH_BUFFER
84 */
85 uint32_t cmd[10];
86};
87
88static inline struct intel_img_view *intel_img_view(XGL_IMAGE_VIEW view)
89{
90 return (struct intel_img_view *) view;
91}
92
93static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj)
94{
95 return (struct intel_img_view *) obj;
96}
97
98static inline struct intel_rt_view *intel_rt_view(XGL_COLOR_ATTACHMENT_VIEW view)
99{
100 return (struct intel_rt_view *) view;
101}
102
103static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj)
104{
105 return (struct intel_rt_view *) obj;
106}
107
108static inline struct intel_ds_view *intel_ds_view(XGL_DEPTH_STENCIL_VIEW view)
109{
110 return (struct intel_ds_view *) view;
111}
112
113static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj)
114{
115 return (struct intel_ds_view *) obj;
116}
117
118void intel_null_view_init(struct intel_null_view *view,
119 struct intel_dev *dev);
120
121void intel_mem_view_init(struct intel_mem_view *view,
122 struct intel_dev *dev,
123 const XGL_MEMORY_VIEW_ATTACH_INFO *info);
124
125XGL_RESULT intel_img_view_create(struct intel_dev *dev,
126 const XGL_IMAGE_VIEW_CREATE_INFO *info,
127 struct intel_img_view **view_ret);
128void intel_img_view_destroy(struct intel_img_view *view);
129
130XGL_RESULT intel_rt_view_create(struct intel_dev *dev,
131 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO *info,
132 struct intel_rt_view **view_ret);
133void intel_rt_view_destroy(struct intel_rt_view *view);
134
135XGL_RESULT intel_ds_view_create(struct intel_dev *dev,
136 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO *info,
137 struct intel_ds_view **view_ret);
138void intel_ds_view_destroy(struct intel_ds_view *view);
139
140XGL_RESULT XGLAPI intelCreateImageView(
141 XGL_DEVICE device,
142 const XGL_IMAGE_VIEW_CREATE_INFO* pCreateInfo,
143 XGL_IMAGE_VIEW* pView);
144
145XGL_RESULT XGLAPI intelCreateColorAttachmentView(
146 XGL_DEVICE device,
147 const XGL_COLOR_ATTACHMENT_VIEW_CREATE_INFO* pCreateInfo,
148 XGL_COLOR_ATTACHMENT_VIEW* pView);
149
150XGL_RESULT XGLAPI intelCreateDepthStencilView(
151 XGL_DEVICE device,
152 const XGL_DEPTH_STENCIL_VIEW_CREATE_INFO* pCreateInfo,
153 XGL_DEPTH_STENCIL_VIEW* pView);
154
155#endif /* VIEW_H */