blob: 9a79e47e5d88696f412f7dccc04b44fa6acd6fbc [file] [log] [blame]
Chia-I Wue46da3e2014-08-08 21:52:48 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wue46da3e2014-08-08 21:52:48 +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 Wue46da3e2014-08-08 21:52:48 +080026 */
27
28#ifndef IMG_H
29#define IMG_H
30
Chia-I Wufeb441f2014-08-08 21:27:38 +080031#include "kmd/winsys.h"
Chia-I Wue46da3e2014-08-08 21:52:48 +080032#include "intel.h"
Chia-I Wu2b685d72014-08-14 13:45:37 +080033#include "layout.h"
Chia-I Wue46da3e2014-08-08 21:52:48 +080034#include "obj.h"
35
Chia-I Wue46da3e2014-08-08 21:52:48 +080036struct intel_img {
37 struct intel_obj obj;
Chia-I Wufeb441f2014-08-08 21:27:38 +080038
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060039 VkImageType type;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060040 int32_t depth;
41 uint32_t mip_levels;
42 uint32_t array_size;
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060043 VkFlags usage;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060044 uint32_t samples;
Chia-I Wu2b685d72014-08-14 13:45:37 +080045 struct intel_layout layout;
Chia-I Wu9b752e12014-08-15 16:21:44 +080046
47 /* layout of separate stencil */
48 struct intel_layout *s8_layout;
49
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060050 size_t total_size;
51 size_t aux_offset;
52 size_t s8_offset;
Chia-I Wu1db76e02014-09-15 14:21:14 +080053
Chia-I Wu41858c82015-04-04 16:39:25 +080054 void *wsi_data;
Chia-I Wue46da3e2014-08-08 21:52:48 +080055};
56
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060057static inline struct intel_img *intel_img(VkImage image)
Chia-I Wufeb441f2014-08-08 21:27:38 +080058{
Tony Barbourde4124d2015-07-03 10:33:54 -060059 return *(struct intel_img **) &image;
Chia-I Wufeb441f2014-08-08 21:27:38 +080060}
61
62static inline struct intel_img *intel_img_from_base(struct intel_base *base)
63{
64 return (struct intel_img *) base;
65}
66
67static inline struct intel_img *intel_img_from_obj(struct intel_obj *obj)
68{
69 return intel_img_from_base(&obj->base);
70}
71
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060072VkResult intel_img_create(struct intel_dev *dev,
73 const VkImageCreateInfo *info,
Chia-I Wu794d12a2014-09-15 14:55:25 +080074 bool scanout,
Chia-I Wufeb441f2014-08-08 21:27:38 +080075 struct intel_img **img_ret);
76
77void intel_img_destroy(struct intel_img *img);
78
Chia-I Wu3defd1f2015-02-18 12:21:22 -070079static inline bool intel_img_can_enable_hiz(const struct intel_img *img,
80 uint32_t level)
81{
82 return (img->layout.aux == INTEL_LAYOUT_AUX_HIZ &&
83 img->layout.aux_enables & (1 << level));
84}
85
Chia-I Wue46da3e2014-08-08 21:52:48 +080086#endif /* IMG_H */