blob: 82aa1d3a74d99f99ccaab173cb4f3a2b3927c01d [file] [log] [blame]
Chia-I Wu82f50aa2014-08-05 10:43:03 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu82f50aa2014-08-05 10:43:03 +08003 *
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 Wu44e42362014-09-02 08:32:09 +080023 *
24 * Authors:
25 * Chia-I Wu <olv@lunarg.com>
Chia-I Wu82f50aa2014-08-05 10:43:03 +080026 */
27
Courtney Goeltzenleuchterfb4fb532014-08-14 09:35:21 -060028#include "dev.h"
Chia-I Wu9e61c0d2014-09-15 15:12:06 +080029#include "gpu.h"
30#include "mem.h"
Chia-I Wu82f50aa2014-08-05 10:43:03 +080031#include "obj.h"
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060032#include "vk_debug_marker_lunarg.h"
Chia-I Wu82f50aa2014-08-05 10:43:03 +080033
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060034VkResult intel_base_get_info(struct intel_base *base, int type,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060035 size_t *size, void *data)
Chia-I Wu26f0bd02014-08-07 10:38:40 +080036{
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060037 VkResult ret = VK_SUCCESS;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060038 size_t s;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080039
40 switch (type) {
Tony Barbour8205d902015-04-16 15:59:00 -060041 case VK_OBJECT_INFO_TYPE_MEMORY_REQUIREMENTS:
Jon Ashburnd8031332015-01-22 10:52:13 -070042 {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060043 s = sizeof(VkMemoryRequirements);
Jon Ashburnd8031332015-01-22 10:52:13 -070044 *size = s;
45 if (data == NULL)
46 return ret;
47 memset(data, 0, s);
Jeremy Hayesd02809a2015-04-15 14:17:56 -060048 VkMemoryRequirements *mem_req = data;
49 mem_req->memPropsAllowed = INTEL_MEMORY_PROPERTY_ALL;
Jon Ashburnd8031332015-01-22 10:52:13 -070050 break;
51 }
Chia-I Wu26f0bd02014-08-07 10:38:40 +080052 default:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060053 ret = VK_ERROR_INVALID_VALUE;
Chia-I Wu26f0bd02014-08-07 10:38:40 +080054 break;
55 }
56
57 return ret;
58}
59
Chia-I Wuf13ed3c2015-02-22 14:09:00 +080060static bool base_dbg_copy_create_info(const struct intel_handle *handle,
61 struct intel_base_dbg *dbg,
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080062 const void *create_info)
63{
64 const union {
65 const void *ptr;
66 const struct {
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060067 VkStructureType struct_type;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060068 void *next;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080069 } *header;
70 } info = { .ptr = create_info };
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -060071 size_t shallow_copy = 0;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080072
73 if (!create_info)
74 return true;
75
Chia-I Wub1076d72014-08-18 16:10:20 +080076 switch (dbg->type) {
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060077 case VK_OBJECT_TYPE_DEVICE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060078 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080079 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060080 case VK_OBJECT_TYPE_DEVICE_MEMORY:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060081 assert(info.header->struct_type == VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080082 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060083 case VK_OBJECT_TYPE_EVENT:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060084 assert(info.header->struct_type == VK_STRUCTURE_TYPE_EVENT_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060085 shallow_copy = sizeof(VkEventCreateInfo);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080086 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060087 case VK_OBJECT_TYPE_FENCE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060088 assert(info.header->struct_type == VK_STRUCTURE_TYPE_FENCE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060089 shallow_copy = sizeof(VkFenceCreateInfo);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +080090 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060091 case VK_OBJECT_TYPE_QUERY_POOL:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060092 assert(info.header->struct_type == VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060093 shallow_copy = sizeof(VkQueryPoolCreateInfo);
Courtney Goeltzenleuchter850d12c2014-08-07 18:13:10 -060094 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060095 case VK_OBJECT_TYPE_BUFFER:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060096 assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -060097 shallow_copy = sizeof(VkBufferCreateInfo);
Chia-I Wu714df452015-01-01 07:55:04 +080098 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060099 case VK_OBJECT_TYPE_BUFFER_VIEW:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600100 assert(info.header->struct_type == VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600101 shallow_copy = sizeof(VkBufferViewCreateInfo);
Chia-I Wu714df452015-01-01 07:55:04 +0800102 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600103 case VK_OBJECT_TYPE_IMAGE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600104 assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600105 shallow_copy = sizeof(VkImageCreateInfo);
Chia-I Wufeb441f2014-08-08 21:27:38 +0800106 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600107 case VK_OBJECT_TYPE_IMAGE_VIEW:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600108 assert(info.header->struct_type == VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600109 shallow_copy = sizeof(VkImageViewCreateInfo);
Chia-I Wu5a323262014-08-11 10:31:53 +0800110 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600111 case VK_OBJECT_TYPE_COLOR_ATTACHMENT_VIEW:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600112 assert(info.header->struct_type == VK_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600113 shallow_copy = sizeof(VkColorAttachmentViewCreateInfo);
Chia-I Wu5a323262014-08-11 10:31:53 +0800114 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600115 case VK_OBJECT_TYPE_DEPTH_STENCIL_VIEW:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600116 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DEPTH_STENCIL_VIEW_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600117 shallow_copy = sizeof(VkDepthStencilViewCreateInfo);
Chia-I Wu5a323262014-08-11 10:31:53 +0800118 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600119 case VK_OBJECT_TYPE_SAMPLER:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600120 assert(info.header->struct_type == VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600121 shallow_copy = sizeof(VkSamplerCreateInfo);
Chia-I Wu28b89962014-08-18 14:40:49 +0800122 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600123 case VK_OBJECT_TYPE_DESCRIPTOR_SET:
Chia-I Wuf8385062015-01-04 16:27:24 +0800124 /* no create info */
Chia-I Wub8d04c82014-08-18 15:51:10 +0800125 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600126 case VK_OBJECT_TYPE_DYNAMIC_VP_STATE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600127 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_VP_STATE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600128 shallow_copy = sizeof(VkDynamicVpStateCreateInfo);
Chia-I Wua5714e82014-08-11 15:33:42 +0800129 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600130 case VK_OBJECT_TYPE_DYNAMIC_RS_STATE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600131 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_RS_STATE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600132 shallow_copy = sizeof(VkDynamicRsStateCreateInfo);
Chia-I Wua5714e82014-08-11 15:33:42 +0800133 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600134 case VK_OBJECT_TYPE_DYNAMIC_CB_STATE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600135 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_CB_STATE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600136 shallow_copy = sizeof(VkDynamicCbStateCreateInfo);
Chia-I Wua5714e82014-08-11 15:33:42 +0800137 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600138 case VK_OBJECT_TYPE_DYNAMIC_DS_STATE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600139 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DYNAMIC_DS_STATE_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600140 shallow_copy = sizeof(VkDynamicDsStateCreateInfo);
Chia-I Wua5714e82014-08-11 15:33:42 +0800141 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600142 case VK_OBJECT_TYPE_COMMAND_BUFFER:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600143 assert(info.header->struct_type == VK_STRUCTURE_TYPE_CMD_BUFFER_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600144 shallow_copy = sizeof(VkCmdBufferCreateInfo);
Chia-I Wu730e5362014-08-19 12:15:09 +0800145 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600146 case VK_OBJECT_TYPE_PIPELINE:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600147 assert(info.header->struct_type == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO);
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600148 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600149 case VK_OBJECT_TYPE_SHADER:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600150 assert(info.header->struct_type == VK_STRUCTURE_TYPE_SHADER_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600151 shallow_copy = sizeof(VkShaderCreateInfo);
Courtney Goeltzenleuchter52ec3362014-08-19 11:52:02 -0600152 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600153 case VK_OBJECT_TYPE_FRAMEBUFFER:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600154 assert(info.header->struct_type == VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600155 shallow_copy = sizeof(VkFramebufferCreateInfo);
Jon Ashburnc6f4a412014-12-24 12:38:36 -0700156 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600157 case VK_OBJECT_TYPE_RENDER_PASS:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600158 assert(info.header->struct_type == VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600159 shallow_copy = sizeof(VkRenderPassCreateInfo);
Jon Ashburnc6f4a412014-12-24 12:38:36 -0700160 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600161 case VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600162 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO);
Chia-I Wuf8385062015-01-04 16:27:24 +0800163 /* TODO */
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600164 shallow_copy = sizeof(VkDescriptorSetLayoutCreateInfo) * 0;
Chia-I Wuf8385062015-01-04 16:27:24 +0800165 break;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600166 case VK_OBJECT_TYPE_DESCRIPTOR_POOL:
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600167 assert(info.header->struct_type == VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600168 shallow_copy = sizeof(VkDescriptorPoolCreateInfo);
Chia-I Wuf8385062015-01-04 16:27:24 +0800169 break;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800170 default:
Chia-I Wu545c2e12015-02-22 13:19:54 +0800171 assert(!"unknown dbg object type");
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800172 return false;
173 break;
174 }
175
176 if (shallow_copy) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800177 dbg->create_info = intel_alloc(handle, shallow_copy, 0,
Tony Barbour8205d902015-04-16 15:59:00 -0600178 VK_SYSTEM_ALLOC_TYPE_DEBUG);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800179 if (!dbg->create_info)
180 return false;
181
182 memcpy(dbg->create_info, create_info, shallow_copy);
Chia-I Wue2934f92014-08-16 13:17:22 +0800183 dbg->create_info_size = shallow_copy;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800184 } else if (info.header->struct_type ==
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600185 VK_STRUCTURE_TYPE_MEMORY_ALLOC_INFO) {
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600186 size_t size;
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500187 const VkMemoryAllocInfo *src = info.ptr;
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600188 VkMemoryAllocInfo *dst;
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700189 uint8_t *d;
190 size = sizeof(*src);
191
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700192 dbg->create_info_size = size;
Tony Barbour8205d902015-04-16 15:59:00 -0600193 dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG);
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700194 if (!dst)
195 return false;
196 memcpy(dst, src, sizeof(*src));
197
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700198 d = (uint8_t *) dst;
199 d += sizeof(*src);
Mark Lobodzinski97dcd042015-04-16 08:52:00 -0500200
Jon Ashburnc6ae13d2015-01-19 15:00:26 -0700201 dbg->create_info = dst;
202 } else if (info.header->struct_type ==
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600203 VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO) {
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600204 const VkDeviceCreateInfo *src = info.ptr;
205 VkDeviceCreateInfo *dst;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800206 uint8_t *d;
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600207 size_t size;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800208
209 size = sizeof(*src);
Chia-I Wue2934f92014-08-16 13:17:22 +0800210 dbg->create_info_size = size;
211
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800212 size += sizeof(src->pRequestedQueues[0]) * src->queueRecordCount;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600213 size += sizeof(src->pEnabledExtensions[0]) * src->extensionCount;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800214
Tony Barbour8205d902015-04-16 15:59:00 -0600215 dst = intel_alloc(handle, size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800216 if (!dst)
217 return false;
218
219 memcpy(dst, src, sizeof(*src));
220
221 d = (uint8_t *) dst;
222 d += sizeof(*src);
223
224 size = sizeof(src->pRequestedQueues[0]) * src->queueRecordCount;
225 memcpy(d, src->pRequestedQueues, size);
Courtney Goeltzenleuchterddcb6192015-04-14 18:48:46 -0600226 dst->pRequestedQueues = (const VkDeviceQueueCreateInfo *) d;
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800227 d += size;
228
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600229 size = sizeof(src->pEnabledExtensions[0]) * src->extensionCount;
230 dst->pEnabledExtensions = (const VkExtensionProperties *) d;
231 memcpy(d, src->pEnabledExtensions, size);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800232
Courtney Goeltzenleuchter191b06c2014-10-17 16:21:35 -0600233 dbg->create_info = dst;
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600234 } else if (info.header->struct_type == VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO) {
Courtney Goeltzenleuchter05a60542014-08-15 14:54:34 -0600235 // TODO: What do we want to copy here?
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800236 }
237
238 return true;
239}
240
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800241/**
Chia-I Wubbf2c932014-08-07 12:20:08 +0800242 * Create an intel_base_dbg. When dbg_size is non-zero, a buffer of that
Chia-I Wu660caf82014-08-07 10:54:26 +0800243 * size is allocated and zeroed.
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800244 */
Chia-I Wu545c2e12015-02-22 13:19:54 +0800245struct intel_base_dbg *intel_base_dbg_create(const struct intel_handle *handle,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600246 VkObjectType type,
Chia-I Wu660caf82014-08-07 10:54:26 +0800247 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600248 size_t dbg_size)
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800249{
Chia-I Wu660caf82014-08-07 10:54:26 +0800250 struct intel_base_dbg *dbg;
251
Chia-I Wubbf2c932014-08-07 12:20:08 +0800252 if (!dbg_size)
253 dbg_size = sizeof(*dbg);
Chia-I Wu660caf82014-08-07 10:54:26 +0800254
Chia-I Wubbf2c932014-08-07 12:20:08 +0800255 assert(dbg_size >= sizeof(*dbg));
Chia-I Wu660caf82014-08-07 10:54:26 +0800256
Tony Barbour8205d902015-04-16 15:59:00 -0600257 dbg = intel_alloc(handle, dbg_size, 0, VK_SYSTEM_ALLOC_TYPE_DEBUG);
Chia-I Wu660caf82014-08-07 10:54:26 +0800258 if (!dbg)
259 return NULL;
260
Chia-I Wubbf2c932014-08-07 12:20:08 +0800261 memset(dbg, 0, dbg_size);
Chia-I Wu660caf82014-08-07 10:54:26 +0800262
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800263 dbg->type = type;
264
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800265 if (!base_dbg_copy_create_info(handle, dbg, create_info)) {
Chia-I Wuf9c81ef2015-02-22 13:49:15 +0800266 intel_free(handle, dbg);
Chia-I Wu1f8fc7c2014-08-07 11:09:11 +0800267 return NULL;
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800268 }
269
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800270 return dbg;
271}
272
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800273void intel_base_dbg_destroy(const struct intel_handle *handle,
274 struct intel_base_dbg *dbg)
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800275{
Chia-I Wu660caf82014-08-07 10:54:26 +0800276 if (dbg->tag)
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800277 intel_free(handle, dbg->tag);
Chia-I Wu660caf82014-08-07 10:54:26 +0800278
279 if (dbg->create_info)
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800280 intel_free(handle, dbg->create_info);
Chia-I Wu660caf82014-08-07 10:54:26 +0800281
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800282 intel_free(handle, dbg);
Chia-I Wu82f50aa2014-08-05 10:43:03 +0800283}
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800284
Chia-I Wubbf2c932014-08-07 12:20:08 +0800285/**
286 * Create an intel_base. obj_size and dbg_size specify the real sizes of the
287 * object and the debug metadata. Memories are zeroed.
288 */
Chia-I Wu545c2e12015-02-22 13:19:54 +0800289struct intel_base *intel_base_create(const struct intel_handle *handle,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600290 size_t obj_size, bool debug,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -0600291 VkObjectType type,
Chia-I Wubbf2c932014-08-07 12:20:08 +0800292 const void *create_info,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600293 size_t dbg_size)
Chia-I Wubbf2c932014-08-07 12:20:08 +0800294{
295 struct intel_base *base;
296
297 if (!obj_size)
298 obj_size = sizeof(*base);
299
300 assert(obj_size >= sizeof(*base));
301
Tony Barbour8205d902015-04-16 15:59:00 -0600302 base = intel_alloc(handle, obj_size, 0, VK_SYSTEM_ALLOC_TYPE_API_OBJECT);
Chia-I Wubbf2c932014-08-07 12:20:08 +0800303 if (!base)
304 return NULL;
305
Chia-I Wu778a80c2015-01-03 22:45:10 +0800306 memset(base, 0, obj_size);
Chia-I Wu032a2e32015-01-19 11:14:00 +0800307 intel_handle_init(&base->handle, type, handle->icd);
Chia-I Wu778a80c2015-01-03 22:45:10 +0800308
Chia-I Wubbf2c932014-08-07 12:20:08 +0800309 if (debug) {
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800310 base->dbg = intel_base_dbg_create(&base->handle,
Chia-I Wu545c2e12015-02-22 13:19:54 +0800311 type, create_info, dbg_size);
Chia-I Wubbf2c932014-08-07 12:20:08 +0800312 if (!base->dbg) {
Chia-I Wuf9c81ef2015-02-22 13:49:15 +0800313 intel_free(handle, base);
Chia-I Wubbf2c932014-08-07 12:20:08 +0800314 return NULL;
315 }
316 }
Chia-I Wu6a42c2a2014-08-19 14:36:47 +0800317
Chia-I Wubbf2c932014-08-07 12:20:08 +0800318 base->get_info = intel_base_get_info;
319
320 return base;
321}
322
323void intel_base_destroy(struct intel_base *base)
324{
325 if (base->dbg)
Chia-I Wuf13ed3c2015-02-22 14:09:00 +0800326 intel_base_dbg_destroy(&base->handle, base->dbg);
Chia-I Wuf9c81ef2015-02-22 13:49:15 +0800327 intel_free(base, base);
Chia-I Wubbf2c932014-08-07 12:20:08 +0800328}
329
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600330ICD_EXPORT VkResult VKAPI vkDestroyObject(
Mike Stroyan230e6252015-04-17 12:36:38 -0600331 VkDevice device,
332 VkObjectType objType,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600333 VkObject object)
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800334{
335 struct intel_obj *obj = intel_obj(object);
336
337 obj->destroy(obj);
338
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600339 return VK_SUCCESS;
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800340}
341
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -0600342ICD_EXPORT VkResult VKAPI vkGetObjectInfo(
Mike Stroyan230e6252015-04-17 12:36:38 -0600343 VkDevice device,
344 VkObjectType objType,
345 VkObject object,
346 VkObjectInfoType infoType,
Mark Lobodzinskie2d07a52015-01-29 08:55:56 -0600347 size_t* pDataSize,
348 void* pData)
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800349{
350 struct intel_base *base = intel_base(object);
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800351
Chia-I Wu26f0bd02014-08-07 10:38:40 +0800352 return base->get_info(base, infoType, pDataSize, pData);
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800353}
354
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500355ICD_EXPORT VkResult VKAPI vkBindObjectMemory(
356 VkDevice device,
Mike Stroyan230e6252015-04-17 12:36:38 -0600357 VkObjectType objType,
358 VkObject object,
Tony Barbour8205d902015-04-16 15:59:00 -0600359 VkDeviceMemory mem_,
360 VkDeviceSize memOffset)
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800361{
362 struct intel_obj *obj = intel_obj(object);
Chia-I Wu9e61c0d2014-09-15 15:12:06 +0800363 struct intel_mem *mem = intel_mem(mem_);
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800364
Chia-I Wu714df452015-01-01 07:55:04 +0800365 intel_obj_bind_mem(obj, mem, memOffset);
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800366
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600367 return VK_SUCCESS;
Chia-I Wu53fc6aa2014-08-06 14:22:51 +0800368}
Chia-I Wu7ec9f342014-08-19 10:47:53 +0800369
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500370ICD_EXPORT VkResult VKAPI vkQueueBindSparseBufferMemory(
Mike Stroyan230e6252015-04-17 12:36:38 -0600371 VkQueue queue,
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500372 VkBuffer buffer,
Tony Barbour8205d902015-04-16 15:59:00 -0600373 VkDeviceSize rangeOffset,
374 VkDeviceSize rangeSize,
375 VkDeviceMemory mem,
376 VkDeviceSize memOffset)
Chia-I Wu714df452015-01-01 07:55:04 +0800377{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600378 return VK_ERROR_UNKNOWN;
Chia-I Wu714df452015-01-01 07:55:04 +0800379}
380
Mark Lobodzinskifb9f5642015-05-11 17:21:15 -0500381ICD_EXPORT VkResult VKAPI vkQueueBindSparseImageMemory(
Tony Barbour8205d902015-04-16 15:59:00 -0600382 VkQueue queue,
383 VkImage image,
Tony Barbour8205d902015-04-16 15:59:00 -0600384 const VkImageMemoryBindInfo* pBindInfo,
385 VkDeviceMemory mem,
386 VkDeviceSize memOffset)
Chia-I Wu714df452015-01-01 07:55:04 +0800387{
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -0600388 return VK_ERROR_UNKNOWN;
Chia-I Wu714df452015-01-01 07:55:04 +0800389}
390