本文整理汇总了C++中VkLayerDispatchTable::CreateBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::CreateBuffer方法的具体用法?C++ VkLayerDispatchTable::CreateBuffer怎么用?C++ VkLayerDispatchTable::CreateBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VkLayerDispatchTable
的用法示例。
在下文中一共展示了VkLayerDispatchTable::CreateBuffer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vkGetSwapchainImagesKHR
VK_LAYER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkGetSwapchainImagesKHR(VkDevice device, VkSwapchainKHR swapChain, uint32_t *pCount,
VkImage *pImages) {
layer_data *my_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
VkLayerDispatchTable *pTable = my_data->device_dispatch_table;
VkResult result = my_data->pfnGetSwapchainImagesKHR(device, swapChain, pCount, pImages);
VkResult U_ASSERT_ONLY err;
/* GetSwapChainImagesWSI may be called without an images buffer, in which
* case it
* just returns the count to the caller. We're only interested in acting on
* the
* /actual/ fetch of the images.
*/
if (pImages) {
auto data = (*my_data->swapChains)[swapChain];
for (uint32_t i = 0; i < *pCount; i++) {
/* Create attachment view for each */
VkImageViewCreateInfo ivci;
ivci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
ivci.viewType = VK_IMAGE_VIEW_TYPE_2D;
ivci.pNext = nullptr;
ivci.format = data->format;
ivci.components.r = VK_COMPONENT_SWIZZLE_R;
ivci.components.g = VK_COMPONENT_SWIZZLE_G;
ivci.components.b = VK_COMPONENT_SWIZZLE_B;
ivci.components.a = VK_COMPONENT_SWIZZLE_A;
ivci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
ivci.subresourceRange.baseMipLevel = 0;
ivci.subresourceRange.levelCount = 1;
ivci.subresourceRange.baseArrayLayer = 0;
ivci.subresourceRange.layerCount = 1;
ivci.image = pImages[i];
ivci.flags = 0;
VkImageView v;
pTable->CreateImageView(device, &ivci, nullptr, &v);
/* Create framebuffer for each */
VkFramebufferCreateInfo fci;
fci.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
fci.pNext = nullptr;
fci.flags = 0;
fci.renderPass = data->render_pass;
fci.attachmentCount = 1;
fci.pAttachments = &v;
fci.width = data->width;
fci.height = data->height;
fci.layers = 1;
VkFramebuffer fb;
pTable->CreateFramebuffer(device, &fci, nullptr, &fb);
/* Create command buffer for each */
VkCommandBufferAllocateInfo cbai;
cbai.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
cbai.pNext = nullptr;
cbai.commandPool = my_data->pool;
cbai.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
cbai.commandBufferCount = 1;
VkCommandBuffer cmd;
pTable->AllocateCommandBuffers(device, &cbai, &cmd);
/* We have just created a dispatchable object, but the dispatch
* table has not been placed in the object yet.
* When a "normal" application creates a command buffer,
* the dispatch table is installed by the top-level binding
* (trampoline.c).
* But here, we have to do it ourselves. */
if (!my_data->pfn_dev_init) {
*((const void **)cmd) = *(void **)device;
} else {
err = my_data->pfn_dev_init(device, (void *)cmd);
assert(!err);
}
/* Create vertex buffer */
VkBufferCreateInfo bci;
memset(&bci, 0, sizeof(bci));
bci.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
bci.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
bci.size = sizeof(vertex) * MAX_TEXT_VERTICES;
VkBuffer buf;
err = pTable->CreateBuffer(device, &bci, nullptr, &buf);
assert(!err);
VkMemoryRequirements mem_reqs;
pTable->GetBufferMemoryRequirements(device, buf, &mem_reqs);
assert(!err);
VkMemoryAllocateInfo mem_alloc;
memset(&mem_alloc, 0, sizeof(mem_alloc));
mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
mem_alloc.allocationSize = mem_reqs.size;
mem_alloc.memoryTypeIndex = choose_memory_type(
my_data->gpu, mem_reqs.memoryTypeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
//.........这里部分代码省略.........