Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 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 Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef VIEW_H |
| 29 | #define VIEW_H |
| 30 | |
| 31 | #include "obj.h" |
| 32 | #include "intel.h" |
| 33 | |
| 34 | struct intel_img; |
| 35 | struct intel_mem; |
| 36 | |
| 37 | struct intel_null_view { |
Chia-I Wu | aabb360 | 2014-08-19 14:18:23 +0800 | [diff] [blame] | 38 | /* this is not an intel_obj */ |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 39 | |
| 40 | /* SURFACE_STATE */ |
| 41 | uint32_t cmd[8]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 42 | uint32_t cmd_len; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 43 | }; |
| 44 | |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 45 | struct intel_buf_view { |
| 46 | struct intel_obj obj; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 47 | |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 48 | struct intel_buf *buf; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 49 | |
| 50 | /* SURFACE_STATE */ |
| 51 | uint32_t cmd[8]; |
Chia-I Wu | 34341ba | 2015-01-16 17:38:37 +0800 | [diff] [blame] | 52 | uint32_t fs_cmd[8]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 53 | uint32_t cmd_len; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct intel_img_view { |
| 57 | struct intel_obj obj; |
| 58 | |
| 59 | struct intel_img *img; |
| 60 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 61 | float min_lod; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 62 | VK_CHANNEL_MAPPING shader_swizzles; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 63 | |
| 64 | /* SURFACE_STATE */ |
| 65 | uint32_t cmd[8]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 66 | uint32_t cmd_len; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 67 | }; |
| 68 | |
| 69 | struct intel_rt_view { |
| 70 | struct intel_obj obj; |
| 71 | |
| 72 | struct intel_img *img; |
| 73 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 74 | uint32_t array_size; |
Mark Lobodzinski | 71fcc2d | 2015-01-27 13:24:03 -0600 | [diff] [blame] | 75 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 76 | /* SURFACE_STATE */ |
| 77 | uint32_t cmd[8]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 78 | uint32_t cmd_len; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | struct intel_ds_view { |
| 82 | struct intel_obj obj; |
| 83 | |
| 84 | struct intel_img *img; |
| 85 | |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 86 | uint32_t array_size; |
Mark Lobodzinski | 71fcc2d | 2015-01-27 13:24:03 -0600 | [diff] [blame] | 87 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 88 | /* |
| 89 | * 3DSTATE_DEPTH_BUFFER |
| 90 | * 3DSTATE_STENCIL_BUFFER |
| 91 | * 3DSTATE_HIER_DEPTH_BUFFER |
| 92 | */ |
| 93 | uint32_t cmd[10]; |
Chia-I Wu | 3defd1f | 2015-02-18 12:21:22 -0700 | [diff] [blame] | 94 | bool has_stencil; |
| 95 | bool has_hiz; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 96 | }; |
| 97 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 98 | static inline struct intel_buf_view *intel_buf_view(VK_BUFFER_VIEW view) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 99 | { |
| 100 | return (struct intel_buf_view *) view; |
| 101 | } |
| 102 | |
| 103 | static inline struct intel_buf_view *intel_buf_view_from_obj(struct intel_obj *obj) |
| 104 | { |
| 105 | return (struct intel_buf_view *) obj; |
| 106 | } |
| 107 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 108 | static inline struct intel_img_view *intel_img_view(VK_IMAGE_VIEW view) |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 109 | { |
| 110 | return (struct intel_img_view *) view; |
| 111 | } |
| 112 | |
| 113 | static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj) |
| 114 | { |
| 115 | return (struct intel_img_view *) obj; |
| 116 | } |
| 117 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 118 | static inline struct intel_rt_view *intel_rt_view(VK_COLOR_ATTACHMENT_VIEW view) |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 119 | { |
| 120 | return (struct intel_rt_view *) view; |
| 121 | } |
| 122 | |
| 123 | static inline struct intel_rt_view *intel_rt_view_from_obj(struct intel_obj *obj) |
| 124 | { |
| 125 | return (struct intel_rt_view *) obj; |
| 126 | } |
| 127 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 128 | static inline struct intel_ds_view *intel_ds_view(VK_DEPTH_STENCIL_VIEW view) |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 129 | { |
| 130 | return (struct intel_ds_view *) view; |
| 131 | } |
| 132 | |
| 133 | static inline struct intel_ds_view *intel_ds_view_from_obj(struct intel_obj *obj) |
| 134 | { |
| 135 | return (struct intel_ds_view *) obj; |
| 136 | } |
| 137 | |
| 138 | void intel_null_view_init(struct intel_null_view *view, |
| 139 | struct intel_dev *dev); |
| 140 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 141 | VK_RESULT intel_buf_view_create(struct intel_dev *dev, |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame^] | 142 | const VkBufferViewCreateInfo *info, |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 143 | struct intel_buf_view **view_ret); |
| 144 | |
| 145 | void intel_buf_view_destroy(struct intel_buf_view *view); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 146 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 147 | VK_RESULT intel_img_view_create(struct intel_dev *dev, |
| 148 | const VK_IMAGE_VIEW_CREATE_INFO *info, |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 149 | struct intel_img_view **view_ret); |
| 150 | void intel_img_view_destroy(struct intel_img_view *view); |
| 151 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 152 | VK_RESULT intel_rt_view_create(struct intel_dev *dev, |
| 153 | const VK_COLOR_ATTACHMENT_VIEW_CREATE_INFO *info, |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 154 | struct intel_rt_view **view_ret); |
| 155 | void intel_rt_view_destroy(struct intel_rt_view *view); |
| 156 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 157 | VK_RESULT intel_ds_view_create(struct intel_dev *dev, |
| 158 | const VK_DEPTH_STENCIL_VIEW_CREATE_INFO *info, |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 159 | struct intel_ds_view **view_ret); |
| 160 | void intel_ds_view_destroy(struct intel_ds_view *view); |
| 161 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 162 | #endif /* VIEW_H */ |