Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +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 | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef OBJ_H |
| 29 | #define OBJ_H |
| 30 | |
| 31 | #include "intel.h" |
| 32 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 33 | struct intel_dev; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 34 | struct intel_mem; |
| 35 | |
| 36 | struct intel_base_dbg { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 37 | VkDbgObjectType type; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 38 | |
| 39 | void *create_info; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 40 | size_t create_info_size; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 41 | |
| 42 | void *tag; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 43 | size_t tag_size; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | struct intel_base { |
Chia-I Wu | 924c1fc | 2015-01-19 11:14:00 +0800 | [diff] [blame] | 47 | struct intel_handle handle; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 48 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 49 | struct intel_base_dbg *dbg; |
| 50 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 51 | VkResult (*get_memory_requirements)(struct intel_base *base, |
| 52 | VkMemoryRequirements *data); |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 53 | }; |
| 54 | |
| 55 | struct intel_obj { |
| 56 | struct intel_base base; |
| 57 | |
| 58 | void (*destroy)(struct intel_obj *obj); |
| 59 | |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 60 | /* for memory binding */ |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 61 | struct intel_mem *mem; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 62 | size_t offset; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 63 | }; |
| 64 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 65 | static inline struct intel_base *intel_base(uint64_t base) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 66 | { |
| 67 | return (struct intel_base *) base; |
| 68 | } |
| 69 | |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 70 | static inline struct intel_obj *intel_obj(uint64_t obj) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 71 | { |
| 72 | return (struct intel_obj *) obj; |
| 73 | } |
| 74 | |
Chia-I Wu | 9e61c0d | 2014-09-15 15:12:06 +0800 | [diff] [blame] | 75 | static inline void intel_obj_bind_mem(struct intel_obj *obj, |
| 76 | struct intel_mem *mem, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 77 | VkDeviceSize offset) |
Chia-I Wu | 9e61c0d | 2014-09-15 15:12:06 +0800 | [diff] [blame] | 78 | { |
| 79 | obj->mem = mem; |
| 80 | obj->offset = offset; |
| 81 | } |
| 82 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 83 | VkResult intel_base_get_memory_requirements(struct intel_base *base, VkMemoryRequirements *data); |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 84 | |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 85 | struct intel_base_dbg *intel_base_dbg_create(const struct intel_handle *handle, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 86 | VkDbgObjectType type, |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 87 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 88 | size_t dbg_size); |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 89 | void intel_base_dbg_destroy(const struct intel_handle *handle, |
| 90 | struct intel_base_dbg *dbg); |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 91 | |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 92 | struct intel_base *intel_base_create(const struct intel_handle *handle, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 93 | size_t obj_size, bool debug, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 94 | VkDbgObjectType type, |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 95 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 96 | size_t dbg_size); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 97 | void intel_base_destroy(struct intel_base *base); |
| 98 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 99 | #endif /* OBJ_H */ |