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 | |
Courtney Goeltzenleuchter | fb4fb53 | 2014-08-14 09:35:21 -0600 | [diff] [blame] | 28 | #include "dev.h" |
Chia-I Wu | 9e61c0d | 2014-09-15 15:12:06 +0800 | [diff] [blame] | 29 | #include "gpu.h" |
| 30 | #include "mem.h" |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 31 | #include "obj.h" |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 32 | #include "vk_debug_marker_lunarg.h" |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 33 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 34 | VkResult intel_base_get_memory_requirements(struct intel_base *base, VkMemoryRequirements* pRequirements) |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 35 | { |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 36 | memset(pRequirements, 0, sizeof(VkMemoryRequirements)); |
Mark Lobodzinski | 7234629 | 2015-07-02 16:49:40 -0600 | [diff] [blame] | 37 | pRequirements->memoryTypeBits = (1<< INTEL_MEMORY_TYPE_COUNT) - 1; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 38 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 39 | return VK_SUCCESS; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 40 | } |
| 41 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 42 | static bool base_dbg_copy_create_info(const struct intel_handle *handle, |
| 43 | struct intel_base_dbg *dbg, |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 44 | const void *create_info) |
| 45 | { |
| 46 | const union { |
| 47 | const void *ptr; |
| 48 | const struct { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 49 | VkStructureType struct_type; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 50 | void *next; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 51 | } *header; |
| 52 | } info = { .ptr = create_info }; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 53 | size_t shallow_copy = 0; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 54 | |
| 55 | if (!create_info) |
| 56 | return true; |
| 57 | |
Chia-I Wu | b1076d7 | 2014-08-18 16:10:20 +0800 | [diff] [blame] | 58 | switch (dbg->type) { |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 59 | case VK_OBJECT_TYPE_DEVICE: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 60 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 61 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 62 | case VK_OBJECT_TYPE_DEVICE_MEMORY: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 63 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 64 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 65 | case VK_OBJECT_TYPE_EVENT: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 66 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 67 | shallow_copy = sizeof(VkEventCreateInfo); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 68 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 69 | case VK_OBJECT_TYPE_FENCE: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 70 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 71 | shallow_copy = sizeof(VkFenceCreateInfo); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 72 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 73 | case VK_OBJECT_TYPE_QUERY_POOL: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 74 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 75 | shallow_copy = sizeof(VkQueryPoolCreateInfo); |
Courtney Goeltzenleuchter | 850d12c | 2014-08-07 18:13:10 -0600 | [diff] [blame] | 76 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 77 | case VK_OBJECT_TYPE_BUFFER: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 78 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 79 | shallow_copy = sizeof(VkBufferCreateInfo); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 80 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 81 | case VK_OBJECT_TYPE_BUFFER_VIEW: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 82 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 83 | shallow_copy = sizeof(VkBufferViewCreateInfo); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 84 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 85 | case VK_OBJECT_TYPE_IMAGE: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 86 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 87 | shallow_copy = sizeof(VkImageCreateInfo); |
Chia-I Wu | feb441f | 2014-08-08 21:27:38 +0800 | [diff] [blame] | 88 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 89 | case VK_OBJECT_TYPE_IMAGE_VIEW: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 90 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 91 | shallow_copy = sizeof(VkImageViewCreateInfo); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 92 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 93 | case VK_OBJECT_TYPE_SAMPLER: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 94 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 95 | shallow_copy = sizeof(VkSamplerCreateInfo); |
Chia-I Wu | 28b8996 | 2014-08-18 14:40:49 +0800 | [diff] [blame] | 96 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 97 | case VK_OBJECT_TYPE_DESCRIPTOR_SET: |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 98 | /* no create info */ |
Chia-I Wu | b8d04c8 | 2014-08-18 15:51:10 +0800 | [diff] [blame] | 99 | break; |
Courtney Goeltzenleuchter | 445be8d | 2015-07-24 09:02:54 -0600 | [diff] [blame] | 100 | case VK_OBJECT_TYPE_CMD_POOL: |
| 101 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_CMD_POOL_CREATE_INFO); |
| 102 | shallow_copy = sizeof(VkCmdPoolCreateInfo); |
| 103 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 104 | case VK_OBJECT_TYPE_COMMAND_BUFFER: |
Courtney Goeltzenleuchter | 831c183 | 2015-10-23 14:21:05 -0600 | [diff] [blame] | 105 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_CMD_BUFFER_ALLOC_INFO); |
| 106 | shallow_copy = sizeof(VkCmdBufferAllocInfo); |
Chia-I Wu | 730e536 | 2014-08-19 12:15:09 +0800 | [diff] [blame] | 107 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 108 | case VK_OBJECT_TYPE_PIPELINE: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 109 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 110 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 111 | case VK_OBJECT_TYPE_SHADER: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 112 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 113 | shallow_copy = sizeof(VkShaderCreateInfo); |
Courtney Goeltzenleuchter | 52ec336 | 2014-08-19 11:52:02 -0600 | [diff] [blame] | 114 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 115 | case VK_OBJECT_TYPE_FRAMEBUFFER: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 116 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 117 | shallow_copy = sizeof(VkFramebufferCreateInfo); |
Jon Ashburn | c6f4a41 | 2014-12-24 12:38:36 -0700 | [diff] [blame] | 118 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 119 | case VK_OBJECT_TYPE_RENDER_PASS: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 120 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 121 | shallow_copy = sizeof(VkRenderPassCreateInfo); |
Jon Ashburn | c6f4a41 | 2014-12-24 12:38:36 -0700 | [diff] [blame] | 122 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 123 | case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO); |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 125 | /* TODO */ |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 126 | shallow_copy = sizeof(VkDescriptorSetLayoutCreateInfo) * 0; |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 127 | break; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame] | 128 | case VK_OBJECT_TYPE_DESCRIPTOR_POOL: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 129 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 130 | shallow_copy = sizeof(VkDescriptorPoolCreateInfo); |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 131 | break; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 132 | default: |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 133 | assert(!"unknown dbg object type"); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 134 | return false; |
| 135 | break; |
| 136 | } |
| 137 | |
| 138 | if (shallow_copy) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 139 | dbg->create_info = intel_alloc(handle, shallow_copy, 0, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 140 | VK_SYSTEM_ALLOC_TYPE_DEBUG); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 141 | if (!dbg->create_info) |
| 142 | return false; |
| 143 | |
| 144 | memcpy(dbg->create_info, create_info, shallow_copy); |
Chia-I Wu | e2934f9 | 2014-08-16 13:17:22 +0800 | [diff] [blame] | 145 | dbg->create_info_size = shallow_copy; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 146 | } else if (info.header->struct_type == |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 147 | VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO) { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 148 | size_t size; |
Mark Lobodzinski | 97dcd04 | 2015-04-16 08:52:00 -0500 | [diff] [blame] | 149 | const VkMemoryAllocInfo *src = info.ptr; |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 150 | VkMemoryAllocInfo *dst; |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 151 | uint8_t *d; |
| 152 | size = sizeof(*src); |
| 153 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 154 | dbg->create_info_size = size; |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 155 | dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG); |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 156 | if (!dst) |
| 157 | return false; |
| 158 | memcpy(dst, src, sizeof(*src)); |
| 159 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 160 | d = (uint8_t *) dst; |
| 161 | d += sizeof(*src); |
Mark Lobodzinski | 97dcd04 | 2015-04-16 08:52:00 -0500 | [diff] [blame] | 162 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 163 | dbg->create_info = dst; |
| 164 | } else if (info.header->struct_type == |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 165 | VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO) { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 166 | const VkDeviceCreateInfo *src = info.ptr; |
| 167 | VkDeviceCreateInfo *dst; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 168 | uint8_t *d; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 169 | size_t size; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 170 | |
| 171 | size = sizeof(*src); |
Chia-I Wu | e2934f9 | 2014-08-16 13:17:22 +0800 | [diff] [blame] | 172 | dbg->create_info_size = size; |
| 173 | |
Courtney Goeltzenleuchter | dfd53f5 | 2015-10-15 16:58:44 -0600 | [diff] [blame] | 174 | size += sizeof(src->pRequestedQueues[0]) * src->requestedQueueCount; |
Courtney Goeltzenleuchter | d3a8d36 | 2015-10-23 10:37:02 -0600 | [diff] [blame] | 175 | for (uint32_t i = 0; i < src->requestedQueueCount; i++) { |
| 176 | size += src->pRequestedQueues[i].queueCount * sizeof(float); |
| 177 | } |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 178 | size += sizeof(src->ppEnabledExtensionNames[0]) * src->extensionCount; |
| 179 | for (uint32_t i = 0; i < src->extensionCount; i++) { |
| 180 | size += strlen(src->ppEnabledExtensionNames[i]) + 1; |
| 181 | } |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 182 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 183 | dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 184 | if (!dst) |
| 185 | return false; |
| 186 | |
| 187 | memcpy(dst, src, sizeof(*src)); |
| 188 | |
| 189 | d = (uint8_t *) dst; |
| 190 | d += sizeof(*src); |
| 191 | |
Courtney Goeltzenleuchter | dfd53f5 | 2015-10-15 16:58:44 -0600 | [diff] [blame] | 192 | size = sizeof(src->pRequestedQueues[0]) * src->requestedQueueCount; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 193 | memcpy(d, src->pRequestedQueues, size); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 194 | dst->pRequestedQueues = (const VkDeviceQueueCreateInfo *) d; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 195 | d += size; |
Courtney Goeltzenleuchter | d3a8d36 | 2015-10-23 10:37:02 -0600 | [diff] [blame] | 196 | for (uint32_t i = 0; i < src->requestedQueueCount; i++) { |
| 197 | size = sizeof(float) * dst->pRequestedQueues[i].queueCount; |
| 198 | memcpy(d, src->pRequestedQueues[i].pQueuePriorities, size); |
| 199 | *((float **) &dst->pRequestedQueues[i].pQueuePriorities) = (float *) d; |
| 200 | d += size; |
| 201 | } |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 202 | |
Courtney Goeltzenleuchter | 18061cd | 2015-06-29 15:39:26 -0600 | [diff] [blame] | 203 | size = sizeof(src->ppEnabledExtensionNames[0]) * src->extensionCount; |
| 204 | dst->ppEnabledExtensionNames = (const char **) d; |
| 205 | memcpy(d, src->ppEnabledExtensionNames, size); |
| 206 | d += size; |
| 207 | for (uint32_t i = 0; i < src->extensionCount; i++) { |
| 208 | char **ptr = (char **) &dst->ppEnabledExtensionNames[i]; |
| 209 | strcpy((char *) d, src->ppEnabledExtensionNames[i]); |
| 210 | *ptr = (char *) d; |
| 211 | d += strlen(src->ppEnabledExtensionNames[i]) + 1; |
| 212 | } |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 213 | |
Courtney Goeltzenleuchter | 191b06c | 2014-10-17 16:21:35 -0600 | [diff] [blame] | 214 | dbg->create_info = dst; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 215 | } else if (info.header->struct_type == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO) { |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 216 | // TODO: What do we want to copy here? |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | return true; |
| 220 | } |
| 221 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 222 | /** |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 223 | * Create an intel_base_dbg. When dbg_size is non-zero, a buffer of that |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 224 | * size is allocated and zeroed. |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 225 | */ |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 226 | 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] | 227 | VkDbgObjectType type, |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 228 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 229 | size_t dbg_size) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 230 | { |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 231 | struct intel_base_dbg *dbg; |
| 232 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 233 | if (!dbg_size) |
| 234 | dbg_size = sizeof(*dbg); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 235 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 236 | assert(dbg_size >= sizeof(*dbg)); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 237 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 238 | dbg = intel_alloc(handle, dbg_size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 239 | if (!dbg) |
| 240 | return NULL; |
| 241 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 242 | memset(dbg, 0, dbg_size); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 243 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 244 | dbg->type = type; |
| 245 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 246 | if (!base_dbg_copy_create_info(handle, dbg, create_info)) { |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 247 | intel_free(handle, dbg); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 248 | return NULL; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 249 | } |
| 250 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 251 | return dbg; |
| 252 | } |
| 253 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 254 | void intel_base_dbg_destroy(const struct intel_handle *handle, |
| 255 | struct intel_base_dbg *dbg) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 256 | { |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 257 | if (dbg->tag) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 258 | intel_free(handle, dbg->tag); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 259 | |
| 260 | if (dbg->create_info) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 261 | intel_free(handle, dbg->create_info); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 262 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 263 | intel_free(handle, dbg); |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 264 | } |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 265 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 266 | /** |
| 267 | * Create an intel_base. obj_size and dbg_size specify the real sizes of the |
| 268 | * object and the debug metadata. Memories are zeroed. |
| 269 | */ |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 270 | struct intel_base *intel_base_create(const struct intel_handle *handle, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 271 | size_t obj_size, bool debug, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 272 | VkDbgObjectType type, |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 273 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 274 | size_t dbg_size) |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 275 | { |
| 276 | struct intel_base *base; |
| 277 | |
| 278 | if (!obj_size) |
| 279 | obj_size = sizeof(*base); |
| 280 | |
| 281 | assert(obj_size >= sizeof(*base)); |
| 282 | |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 283 | base = intel_alloc(handle, obj_size, 0, VK_SYSTEM_ALLOC_TYPE_API_OBJECT); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 284 | if (!base) |
| 285 | return NULL; |
| 286 | |
Chia-I Wu | 778a80c | 2015-01-03 22:45:10 +0800 | [diff] [blame] | 287 | memset(base, 0, obj_size); |
Courtney Goeltzenleuchter | 9ecf685 | 2015-06-09 08:22:48 -0600 | [diff] [blame] | 288 | intel_handle_init(&base->handle, type, handle->instance); |
Chia-I Wu | 778a80c | 2015-01-03 22:45:10 +0800 | [diff] [blame] | 289 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 290 | if (debug) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 291 | base->dbg = intel_base_dbg_create(&base->handle, |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 292 | type, create_info, dbg_size); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 293 | if (!base->dbg) { |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 294 | intel_free(handle, base); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 295 | return NULL; |
| 296 | } |
| 297 | } |
Chia-I Wu | 6a42c2a | 2014-08-19 14:36:47 +0800 | [diff] [blame] | 298 | |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 299 | base->get_memory_requirements = intel_base_get_memory_requirements; |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 300 | |
| 301 | return base; |
| 302 | } |
| 303 | |
| 304 | void intel_base_destroy(struct intel_base *base) |
| 305 | { |
| 306 | if (base->dbg) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 307 | intel_base_dbg_destroy(&base->handle, base->dbg); |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 308 | intel_free(base, base); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 309 | } |
| 310 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 311 | ICD_EXPORT void VKAPI vkGetBufferMemoryRequirements( |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 312 | VkDevice device, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 313 | VkBuffer buffer, |
Tony Barbour | 426b905 | 2015-06-24 16:06:58 -0600 | [diff] [blame] | 314 | VkMemoryRequirements* pRequirements) |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 315 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 316 | struct intel_base *base = intel_base(buffer.handle); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 317 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 318 | base->get_memory_requirements(base, pRequirements); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 319 | } |
| 320 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 321 | ICD_EXPORT void VKAPI vkGetImageMemoryRequirements( |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 322 | VkDevice device, |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 323 | VkImage image, |
| 324 | VkMemoryRequirements* pRequirements) |
| 325 | { |
| 326 | struct intel_base *base = intel_base(image.handle); |
| 327 | |
Courtney Goeltzenleuchter | 01d2ae1 | 2015-10-20 16:40:38 -0600 | [diff] [blame] | 328 | base->get_memory_requirements(base, pRequirements); |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | ICD_EXPORT VkResult VKAPI vkBindBufferMemory( |
| 332 | VkDevice device, |
| 333 | VkBuffer buffer, |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 334 | VkDeviceMemory mem_, |
| 335 | VkDeviceSize memOffset) |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 336 | { |
Tony Barbour | de4124d | 2015-07-03 10:33:54 -0600 | [diff] [blame] | 337 | struct intel_obj *obj = intel_obj(buffer.handle); |
| 338 | struct intel_mem *mem = intel_mem(mem_); |
| 339 | |
| 340 | intel_obj_bind_mem(obj, mem, memOffset); |
| 341 | |
| 342 | return VK_SUCCESS; |
| 343 | } |
| 344 | |
| 345 | ICD_EXPORT VkResult VKAPI vkBindImageMemory( |
| 346 | VkDevice device, |
| 347 | VkImage image, |
| 348 | VkDeviceMemory mem_, |
| 349 | VkDeviceSize memOffset) |
| 350 | { |
| 351 | struct intel_obj *obj = intel_obj(image.handle); |
Chia-I Wu | 9e61c0d | 2014-09-15 15:12:06 +0800 | [diff] [blame] | 352 | struct intel_mem *mem = intel_mem(mem_); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 353 | |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 354 | intel_obj_bind_mem(obj, mem, memOffset); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 355 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 356 | return VK_SUCCESS; |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 357 | } |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 358 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 359 | ICD_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory( |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 360 | VkQueue queue, |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 361 | VkBuffer buffer, |
Mark Lobodzinski | 83d4e6a | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 362 | uint32_t numBindings, |
| 363 | const VkSparseMemoryBindInfo* pBindInfo) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 364 | { |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 365 | assert(0 && "vkQueueBindSparseBufferMemory not supported"); |
| 366 | return VK_SUCCESS; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 367 | } |
| 368 | |
Mark Lobodzinski | 83d4e6a | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 369 | ICD_EXPORT VkResult VKAPI vkQueueBindSparseImageOpaqueMemory( |
| 370 | VkQueue queue, |
| 371 | VkImage image, |
| 372 | uint32_t numBindings, |
| 373 | const VkSparseMemoryBindInfo* pBindInfo) |
| 374 | { |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 375 | assert(0 && "vkQueueBindSparseImageOpaqueMemory not supported"); |
| 376 | return VK_SUCCESS; |
Mark Lobodzinski | 83d4e6a | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 377 | } |
| 378 | |
| 379 | |
Mark Lobodzinski | fb9f564 | 2015-05-11 17:21:15 -0500 | [diff] [blame] | 380 | ICD_EXPORT VkResult VKAPI vkQueueBindSparseImageMemory( |
Tony Barbour | 8205d90 | 2015-04-16 15:59:00 -0600 | [diff] [blame] | 381 | VkQueue queue, |
| 382 | VkImage image, |
Mark Lobodzinski | 83d4e6a | 2015-07-03 15:58:09 -0600 | [diff] [blame] | 383 | uint32_t numBindings, |
| 384 | const VkSparseImageMemoryBindInfo* pBindInfo) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 385 | { |
Courtney Goeltzenleuchter | ac544f3 | 2015-09-14 18:01:17 -0600 | [diff] [blame] | 386 | assert(0 && "vkQueueBindSparseImageMemory not supported"); |
| 387 | return VK_SUCCESS; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 388 | } |
| 389 | |