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 | |
Chia-I Wu | 3d4d4a6 | 2015-07-09 10:34:10 +0800 | [diff] [blame] | 56 | struct intel_att_view { |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 57 | struct intel_img *img; |
| 58 | |
Chris Forbes | fff9bf4 | 2015-06-15 15:26:19 +1200 | [diff] [blame] | 59 | uint32_t mipLevel; |
Courtney Goeltzenleuchter | 3dee808 | 2015-09-10 16:38:41 -0600 | [diff] [blame] | 60 | uint32_t baseArrayLayer; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 61 | uint32_t array_size; |
Mark Lobodzinski | 71fcc2d | 2015-01-27 13:24:03 -0600 | [diff] [blame] | 62 | |
Chia-I Wu | 3d4d4a6 | 2015-07-09 10:34:10 +0800 | [diff] [blame] | 63 | /* SURFACE_STATE for readback */ |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 64 | uint32_t cmd[8]; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 65 | uint32_t cmd_len; |
Mark Lobodzinski | 71fcc2d | 2015-01-27 13:24:03 -0600 | [diff] [blame] | 66 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 67 | /* |
Chia-I Wu | 3d4d4a6 | 2015-07-09 10:34:10 +0800 | [diff] [blame] | 68 | * SURFACE_STATE when is_rt is true. Otherwise, |
| 69 | * |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 70 | * 3DSTATE_DEPTH_BUFFER |
| 71 | * 3DSTATE_STENCIL_BUFFER |
| 72 | * 3DSTATE_HIER_DEPTH_BUFFER |
| 73 | */ |
Chia-I Wu | 3d4d4a6 | 2015-07-09 10:34:10 +0800 | [diff] [blame] | 74 | uint32_t att_cmd[10]; |
| 75 | bool is_rt; |
Chia-I Wu | 3defd1f | 2015-02-18 12:21:22 -0700 | [diff] [blame] | 76 | bool has_stencil; |
| 77 | bool has_hiz; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 78 | }; |
| 79 | |
Courtney Goeltzenleuchter | 1856d6f | 2015-09-01 17:30:39 -0600 | [diff] [blame] | 80 | struct intel_img_view { |
| 81 | struct intel_obj obj; |
| 82 | |
| 83 | struct intel_img *img; |
| 84 | |
| 85 | VkChannelMapping shader_swizzles; |
| 86 | |
| 87 | /* SURFACE_STATE */ |
| 88 | uint32_t cmd[8]; |
| 89 | uint32_t cmd_len; |
| 90 | |
| 91 | struct intel_att_view att_view; |
| 92 | }; |
| 93 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 94 | static inline struct intel_buf_view *intel_buf_view(VkBufferView view) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 95 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 96 | return *(struct intel_buf_view **) &view; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | static inline struct intel_buf_view *intel_buf_view_from_obj(struct intel_obj *obj) |
| 100 | { |
| 101 | return (struct intel_buf_view *) obj; |
| 102 | } |
| 103 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 104 | static inline struct intel_img_view *intel_img_view(VkImageView view) |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 105 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 106 | return *(struct intel_img_view **) &view; |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | static inline struct intel_img_view *intel_img_view_from_obj(struct intel_obj *obj) |
| 110 | { |
| 111 | return (struct intel_img_view *) obj; |
| 112 | } |
| 113 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 114 | void intel_null_view_init(struct intel_null_view *view, |
| 115 | struct intel_dev *dev); |
| 116 | |
Courtney Goeltzenleuchter | 2a3e3a3 | 2015-09-11 15:29:21 -0600 | [diff] [blame] | 117 | void intel_buf_view_init(struct intel_dev *dev, |
| 118 | const VkBufferViewCreateInfo *info, |
Courtney Goeltzenleuchter | 4f7bb0a | 2015-09-14 16:36:13 -0600 | [diff] [blame] | 119 | struct intel_buf_view *view, |
| 120 | bool raw); |
Courtney Goeltzenleuchter | 2a3e3a3 | 2015-09-11 15:29:21 -0600 | [diff] [blame] | 121 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 122 | VkResult intel_buf_view_create(struct intel_dev *dev, |
Courtney Goeltzenleuchter | 2a3e3a3 | 2015-09-11 15:29:21 -0600 | [diff] [blame] | 123 | const VkBufferViewCreateInfo *info, |
| 124 | struct intel_buf_view **view_ret); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 125 | |
| 126 | void intel_buf_view_destroy(struct intel_buf_view *view); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 127 | |
Courtney Goeltzenleuchter | 1856d6f | 2015-09-01 17:30:39 -0600 | [diff] [blame] | 128 | void intel_img_view_init(struct intel_dev *dev, const VkImageViewCreateInfo *info, |
| 129 | struct intel_img_view *view); |
| 130 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 131 | VkResult intel_img_view_create(struct intel_dev *dev, |
| 132 | const VkImageViewCreateInfo *info, |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 133 | struct intel_img_view **view_ret); |
| 134 | void intel_img_view_destroy(struct intel_img_view *view); |
| 135 | |
Courtney Goeltzenleuchter | 1856d6f | 2015-09-01 17:30:39 -0600 | [diff] [blame] | 136 | void intel_att_view_init(struct intel_dev *dev, |
| 137 | const VkImageViewCreateInfo *info, |
| 138 | struct intel_att_view *att_view); |
Chia-I Wu | 3d4d4a6 | 2015-07-09 10:34:10 +0800 | [diff] [blame] | 139 | void intel_att_view_destroy(struct intel_att_view *view); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 140 | |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 141 | #endif /* VIEW_H */ |