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" |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 32 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 33 | VkResult intel_base_get_info(struct intel_base *base, int type, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 34 | size_t *size, void *data) |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 35 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 36 | VkResult ret = VK_SUCCESS; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 37 | size_t s; |
| 38 | uint32_t *count; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 39 | |
| 40 | switch (type) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 41 | case VK_INFO_TYPE_MEMORY_REQUIREMENTS: |
Jon Ashburn | d803133 | 2015-01-22 10:52:13 -0700 | [diff] [blame] | 42 | { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 43 | s = sizeof(VkMemoryRequirements); |
Jon Ashburn | d803133 | 2015-01-22 10:52:13 -0700 | [diff] [blame] | 44 | *size = s; |
| 45 | if (data == NULL) |
| 46 | return ret; |
| 47 | memset(data, 0, s); |
Jon Ashburn | d803133 | 2015-01-22 10:52:13 -0700 | [diff] [blame] | 48 | break; |
| 49 | } |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 50 | case VK_INFO_TYPE_MEMORY_ALLOCATION_COUNT: |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 51 | *size = sizeof(uint32_t); |
Jon Ashburn | a9ae383 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 52 | if (data == NULL) |
| 53 | return ret; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 54 | count = (uint32_t *) data; |
Jon Ashburn | a9ae383 | 2015-01-16 09:37:43 -0700 | [diff] [blame] | 55 | *count = 1; |
| 56 | break; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 57 | default: |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 58 | ret = VK_ERROR_INVALID_VALUE; |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 59 | break; |
| 60 | } |
| 61 | |
| 62 | return ret; |
| 63 | } |
| 64 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 65 | static bool base_dbg_copy_create_info(const struct intel_handle *handle, |
| 66 | struct intel_base_dbg *dbg, |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 67 | const void *create_info) |
| 68 | { |
| 69 | const union { |
| 70 | const void *ptr; |
| 71 | const struct { |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 72 | VkStructureType struct_type; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 73 | void *next; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 74 | } *header; |
| 75 | } info = { .ptr = create_info }; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 76 | size_t shallow_copy = 0; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 77 | |
| 78 | if (!create_info) |
| 79 | return true; |
| 80 | |
Chia-I Wu | b1076d7 | 2014-08-18 16:10:20 +0800 | [diff] [blame] | 81 | switch (dbg->type) { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 82 | case VK_DBG_OBJECT_DEVICE: |
| 83 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 84 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 85 | case VK_DBG_OBJECT_GPU_MEMORY: |
| 86 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 87 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 88 | case VK_DBG_OBJECT_EVENT: |
| 89 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 90 | shallow_copy = sizeof(VkEventCreateInfo); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 91 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 92 | case VK_DBG_OBJECT_FENCE: |
| 93 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 94 | shallow_copy = sizeof(VkFenceCreateInfo); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 95 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 96 | case VK_DBG_OBJECT_QUERY_POOL: |
| 97 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 98 | shallow_copy = sizeof(VkQueryPoolCreateInfo); |
Courtney Goeltzenleuchter | 850d12c | 2014-08-07 18:13:10 -0600 | [diff] [blame] | 99 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 100 | case VK_DBG_OBJECT_BUFFER: |
| 101 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 102 | shallow_copy = sizeof(VkBufferCreateInfo); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 103 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 104 | case VK_DBG_OBJECT_BUFFER_VIEW: |
| 105 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 106 | shallow_copy = sizeof(VkBufferViewCreateInfo); |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 107 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 108 | case VK_DBG_OBJECT_IMAGE: |
| 109 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 110 | shallow_copy = sizeof(VkImageCreateInfo); |
Chia-I Wu | feb441f | 2014-08-08 21:27:38 +0800 | [diff] [blame] | 111 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 112 | case VK_DBG_OBJECT_IMAGE_VIEW: |
| 113 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 114 | shallow_copy = sizeof(VkImageViewCreateInfo); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 115 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 116 | case VK_DBG_OBJECT_COLOR_TARGET_VIEW: |
| 117 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 118 | shallow_copy = sizeof(VkColorAttachmentViewCreateInfo); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 119 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 120 | case VK_DBG_OBJECT_DEPTH_STENCIL_VIEW: |
| 121 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 122 | shallow_copy = sizeof(VkDepthStencilViewCreateInfo); |
Chia-I Wu | 5a32326 | 2014-08-11 10:31:53 +0800 | [diff] [blame] | 123 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 124 | case VK_DBG_OBJECT_SAMPLER: |
| 125 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 126 | shallow_copy = sizeof(VkSamplerCreateInfo); |
Chia-I Wu | 28b8996 | 2014-08-18 14:40:49 +0800 | [diff] [blame] | 127 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 128 | case VK_DBG_OBJECT_DESCRIPTOR_SET: |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 129 | /* no create info */ |
Chia-I Wu | b8d04c8 | 2014-08-18 15:51:10 +0800 | [diff] [blame] | 130 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 131 | case VK_DBG_OBJECT_VIEWPORT_STATE: |
| 132 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 133 | shallow_copy = sizeof(VkDynamicVpStateCreateInfo); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 134 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 135 | case VK_DBG_OBJECT_RASTER_STATE: |
| 136 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 137 | shallow_copy = sizeof(VkDynamicRsStateCreateInfo); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 138 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 139 | case VK_DBG_OBJECT_COLOR_BLEND_STATE: |
| 140 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 141 | shallow_copy = sizeof(VkDynamicCbStateCreateInfo); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 142 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 143 | case VK_DBG_OBJECT_DEPTH_STENCIL_STATE: |
| 144 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 145 | shallow_copy = sizeof(VkDynamicDsStateCreateInfo); |
Chia-I Wu | a5714e8 | 2014-08-11 15:33:42 +0800 | [diff] [blame] | 146 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 147 | case VK_DBG_OBJECT_CMD_BUFFER: |
| 148 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 149 | shallow_copy = sizeof(VkCmdBufferCreateInfo); |
Chia-I Wu | 730e536 | 2014-08-19 12:15:09 +0800 | [diff] [blame] | 150 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 151 | case VK_DBG_OBJECT_GRAPHICS_PIPELINE: |
| 152 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO); |
Courtney Goeltzenleuchter | 05a6054 | 2014-08-15 14:54:34 -0600 | [diff] [blame] | 153 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 154 | case VK_DBG_OBJECT_SHADER: |
| 155 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 156 | shallow_copy = sizeof(VkShaderCreateInfo); |
Courtney Goeltzenleuchter | 52ec336 | 2014-08-19 11:52:02 -0600 | [diff] [blame] | 157 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 158 | case VK_DBG_OBJECT_FRAMEBUFFER: |
| 159 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 160 | shallow_copy = sizeof(VkFramebufferCreateInfo); |
Jon Ashburn | c6f4a41 | 2014-12-24 12:38:36 -0700 | [diff] [blame] | 161 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 162 | case VK_DBG_OBJECT_RENDER_PASS: |
| 163 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 164 | shallow_copy = sizeof(VkRenderPassCreateInfo); |
Jon Ashburn | c6f4a41 | 2014-12-24 12:38:36 -0700 | [diff] [blame] | 165 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 166 | case VK_DBG_OBJECT_DESCRIPTOR_SET_LAYOUT: |
| 167 | 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] | 168 | /* TODO */ |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 169 | shallow_copy = sizeof(VkDescriptorSetLayoutCreateInfo) * 0; |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 170 | break; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 171 | case VK_DBG_OBJECT_DESCRIPTOR_POOL: |
| 172 | assert(info.header->struct_type == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 173 | shallow_copy = sizeof(VkDescriptorPoolCreateInfo); |
Chia-I Wu | f838506 | 2015-01-04 16:27:24 +0800 | [diff] [blame] | 174 | break; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 175 | default: |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 176 | assert(!"unknown dbg object type"); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 177 | return false; |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | if (shallow_copy) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 182 | dbg->create_info = intel_alloc(handle, shallow_copy, 0, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 183 | VK_SYSTEM_ALLOC_DEBUG); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 184 | if (!dbg->create_info) |
| 185 | return false; |
| 186 | |
| 187 | memcpy(dbg->create_info, create_info, shallow_copy); |
Chia-I Wu | e2934f9 | 2014-08-16 13:17:22 +0800 | [diff] [blame] | 188 | dbg->create_info_size = shallow_copy; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 189 | } else if (info.header->struct_type == |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 190 | VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO) { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 191 | size_t size; |
Mark Lobodzinski | 97dcd04 | 2015-04-16 08:52:00 -0500 | [diff] [blame^] | 192 | const VkMemoryAllocInfo *src = info.ptr; |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 193 | VkMemoryAllocInfo *dst; |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 194 | uint8_t *d; |
| 195 | size = sizeof(*src); |
| 196 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 197 | dbg->create_info_size = size; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 198 | dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_DEBUG); |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 199 | if (!dst) |
| 200 | return false; |
| 201 | memcpy(dst, src, sizeof(*src)); |
| 202 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 203 | d = (uint8_t *) dst; |
| 204 | d += sizeof(*src); |
Mark Lobodzinski | 97dcd04 | 2015-04-16 08:52:00 -0500 | [diff] [blame^] | 205 | |
Jon Ashburn | c6ae13d | 2015-01-19 15:00:26 -0700 | [diff] [blame] | 206 | dbg->create_info = dst; |
| 207 | } else if (info.header->struct_type == |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 208 | VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO) { |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 209 | const VkDeviceCreateInfo *src = info.ptr; |
| 210 | VkDeviceCreateInfo *dst; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 211 | uint8_t *d; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 212 | size_t size; |
| 213 | uint32_t i; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 214 | |
| 215 | size = sizeof(*src); |
Chia-I Wu | e2934f9 | 2014-08-16 13:17:22 +0800 | [diff] [blame] | 216 | dbg->create_info_size = size; |
| 217 | |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 218 | size += sizeof(src->pRequestedQueues[0]) * src->queueRecordCount; |
| 219 | size += sizeof(src->ppEnabledExtensionNames[0]) * src->extensionCount; |
| 220 | for (i = 0; i < src->extensionCount; i++) { |
Chia-I Wu | 7461fcf | 2014-12-27 15:16:07 +0800 | [diff] [blame] | 221 | size += 1 + strlen(src->ppEnabledExtensionNames[i]); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 222 | } |
| 223 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 224 | dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_DEBUG); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 225 | if (!dst) |
| 226 | return false; |
| 227 | |
| 228 | memcpy(dst, src, sizeof(*src)); |
| 229 | |
| 230 | d = (uint8_t *) dst; |
| 231 | d += sizeof(*src); |
| 232 | |
| 233 | size = sizeof(src->pRequestedQueues[0]) * src->queueRecordCount; |
| 234 | memcpy(d, src->pRequestedQueues, size); |
Courtney Goeltzenleuchter | ddcb619 | 2015-04-14 18:48:46 -0600 | [diff] [blame] | 235 | dst->pRequestedQueues = (const VkDeviceQueueCreateInfo *) d; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 236 | d += size; |
| 237 | |
| 238 | size = sizeof(src->ppEnabledExtensionNames[0]) * src->extensionCount; |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 239 | dst->ppEnabledExtensionNames = (const char * const *) d; |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 240 | |
| 241 | for (i = 0; i < src->extensionCount; i++) { |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 242 | const size_t len = strlen(src->ppEnabledExtensionNames[i]); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 243 | |
| 244 | memcpy(d + size, src->ppEnabledExtensionNames[i], len + 1); |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 245 | ((const char **) d)[i] = (const char *) (d + size); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 246 | |
| 247 | size += len + 1; |
| 248 | } |
Courtney Goeltzenleuchter | 191b06c | 2014-10-17 16:21:35 -0600 | [diff] [blame] | 249 | dbg->create_info = dst; |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 250 | } 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] | 251 | // TODO: What do we want to copy here? |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | return true; |
| 255 | } |
| 256 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 257 | /** |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 258 | * 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] | 259 | * size is allocated and zeroed. |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 260 | */ |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 261 | struct intel_base_dbg *intel_base_dbg_create(const struct intel_handle *handle, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 262 | VK_DBG_OBJECT_TYPE type, |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 263 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 264 | size_t dbg_size) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 265 | { |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 266 | struct intel_base_dbg *dbg; |
| 267 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 268 | if (!dbg_size) |
| 269 | dbg_size = sizeof(*dbg); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 270 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 271 | assert(dbg_size >= sizeof(*dbg)); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 272 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 273 | dbg = intel_alloc(handle, dbg_size, 0, VK_SYSTEM_ALLOC_DEBUG); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 274 | if (!dbg) |
| 275 | return NULL; |
| 276 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 277 | memset(dbg, 0, dbg_size); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 278 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 279 | dbg->type = type; |
| 280 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 281 | if (!base_dbg_copy_create_info(handle, dbg, create_info)) { |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 282 | intel_free(handle, dbg); |
Chia-I Wu | 1f8fc7c | 2014-08-07 11:09:11 +0800 | [diff] [blame] | 283 | return NULL; |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 284 | } |
| 285 | |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 286 | return dbg; |
| 287 | } |
| 288 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 289 | void intel_base_dbg_destroy(const struct intel_handle *handle, |
| 290 | struct intel_base_dbg *dbg) |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 291 | { |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 292 | if (dbg->tag) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 293 | intel_free(handle, dbg->tag); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 294 | |
| 295 | if (dbg->create_info) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 296 | intel_free(handle, dbg->create_info); |
Chia-I Wu | 660caf8 | 2014-08-07 10:54:26 +0800 | [diff] [blame] | 297 | |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 298 | intel_free(handle, dbg); |
Chia-I Wu | 82f50aa | 2014-08-05 10:43:03 +0800 | [diff] [blame] | 299 | } |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 300 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 301 | /** |
| 302 | * Create an intel_base. obj_size and dbg_size specify the real sizes of the |
| 303 | * object and the debug metadata. Memories are zeroed. |
| 304 | */ |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 305 | struct intel_base *intel_base_create(const struct intel_handle *handle, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 306 | size_t obj_size, bool debug, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 307 | VK_DBG_OBJECT_TYPE type, |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 308 | const void *create_info, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 309 | size_t dbg_size) |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 310 | { |
| 311 | struct intel_base *base; |
| 312 | |
| 313 | if (!obj_size) |
| 314 | obj_size = sizeof(*base); |
| 315 | |
| 316 | assert(obj_size >= sizeof(*base)); |
| 317 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 318 | base = intel_alloc(handle, obj_size, 0, VK_SYSTEM_ALLOC_API_OBJECT); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 319 | if (!base) |
| 320 | return NULL; |
| 321 | |
Chia-I Wu | 778a80c | 2015-01-03 22:45:10 +0800 | [diff] [blame] | 322 | memset(base, 0, obj_size); |
Chia-I Wu | 032a2e3 | 2015-01-19 11:14:00 +0800 | [diff] [blame] | 323 | intel_handle_init(&base->handle, type, handle->icd); |
Chia-I Wu | 778a80c | 2015-01-03 22:45:10 +0800 | [diff] [blame] | 324 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 325 | if (debug) { |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 326 | base->dbg = intel_base_dbg_create(&base->handle, |
Chia-I Wu | 545c2e1 | 2015-02-22 13:19:54 +0800 | [diff] [blame] | 327 | type, create_info, dbg_size); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 328 | if (!base->dbg) { |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 329 | intel_free(handle, base); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 330 | return NULL; |
| 331 | } |
| 332 | } |
Chia-I Wu | 6a42c2a | 2014-08-19 14:36:47 +0800 | [diff] [blame] | 333 | |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 334 | base->get_info = intel_base_get_info; |
| 335 | |
| 336 | return base; |
| 337 | } |
| 338 | |
| 339 | void intel_base_destroy(struct intel_base *base) |
| 340 | { |
| 341 | if (base->dbg) |
Chia-I Wu | f13ed3c | 2015-02-22 14:09:00 +0800 | [diff] [blame] | 342 | intel_base_dbg_destroy(&base->handle, base->dbg); |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 343 | intel_free(base, base); |
Chia-I Wu | bbf2c93 | 2014-08-07 12:20:08 +0800 | [diff] [blame] | 344 | } |
| 345 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 346 | ICD_EXPORT VkResult VKAPI vkDestroyObject( |
| 347 | VkObject object) |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 348 | { |
| 349 | struct intel_obj *obj = intel_obj(object); |
| 350 | |
| 351 | obj->destroy(obj); |
| 352 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 353 | return VK_SUCCESS; |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 354 | } |
| 355 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 356 | ICD_EXPORT VkResult VKAPI vkGetObjectInfo( |
| 357 | VkBaseObject object, |
| 358 | VkObjectInfoType infoType, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 359 | size_t* pDataSize, |
| 360 | void* pData) |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 361 | { |
| 362 | struct intel_base *base = intel_base(object); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 363 | |
Chia-I Wu | 26f0bd0 | 2014-08-07 10:38:40 +0800 | [diff] [blame] | 364 | return base->get_info(base, infoType, pDataSize, pData); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 365 | } |
| 366 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 367 | ICD_EXPORT VkResult VKAPI vkBindObjectMemory( |
| 368 | VkObject object, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 369 | uint32_t allocationIdx, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 370 | VkGpuMemory mem_, |
| 371 | VkGpuSize memOffset) |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 372 | { |
| 373 | struct intel_obj *obj = intel_obj(object); |
Chia-I Wu | 9e61c0d | 2014-09-15 15:12:06 +0800 | [diff] [blame] | 374 | struct intel_mem *mem = intel_mem(mem_); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 375 | |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 376 | intel_obj_bind_mem(obj, mem, memOffset); |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 377 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 378 | return VK_SUCCESS; |
Chia-I Wu | 53fc6aa | 2014-08-06 14:22:51 +0800 | [diff] [blame] | 379 | } |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 380 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 381 | ICD_EXPORT VkResult VKAPI vkBindObjectMemoryRange( |
| 382 | VkObject object, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 383 | uint32_t allocationIdx, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 384 | VkGpuSize rangeOffset, |
| 385 | VkGpuSize rangeSize, |
| 386 | VkGpuMemory mem, |
| 387 | VkGpuSize memOffset) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 388 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 389 | return VK_ERROR_UNKNOWN; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 390 | } |
| 391 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 392 | ICD_EXPORT VkResult VKAPI vkBindImageMemoryRange( |
| 393 | VkImage image, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 394 | uint32_t allocationIdx, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 395 | const VkImageMemoryBindInfo* bindInfo, |
| 396 | VkGpuMemory mem, |
| 397 | VkGpuSize memOffset) |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 398 | { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 399 | return VK_ERROR_UNKNOWN; |
Chia-I Wu | 714df45 | 2015-01-01 07:55:04 +0800 | [diff] [blame] | 400 | } |
| 401 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 402 | ICD_EXPORT VkResult VKAPI vkDbgSetObjectTag( |
| 403 | VkBaseObject object, |
Mark Lobodzinski | e2d07a5 | 2015-01-29 08:55:56 -0600 | [diff] [blame] | 404 | size_t tagSize, |
| 405 | const void* pTag) |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 406 | { |
| 407 | struct intel_base *base = intel_base(object); |
| 408 | struct intel_base_dbg *dbg = base->dbg; |
| 409 | void *tag; |
| 410 | |
| 411 | if (!dbg) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 412 | return VK_SUCCESS; |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 413 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 414 | tag = intel_alloc(base, tagSize, 0, VK_SYSTEM_ALLOC_DEBUG); |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 415 | if (!tag) |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 416 | return VK_ERROR_OUT_OF_MEMORY; |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 417 | |
| 418 | memcpy(tag, pTag, tagSize); |
| 419 | |
| 420 | if (dbg->tag) |
Chia-I Wu | f9c81ef | 2015-02-22 13:49:15 +0800 | [diff] [blame] | 421 | intel_free(base, dbg->tag); |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 422 | |
| 423 | dbg->tag = tag; |
| 424 | dbg->tag_size = tagSize; |
| 425 | |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 426 | return VK_SUCCESS; |
Chia-I Wu | 7ec9f34 | 2014-08-19 10:47:53 +0800 | [diff] [blame] | 427 | } |