本文整理汇总了C++中VkLayerDispatchTable::CmdBindVertexBuffers方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::CmdBindVertexBuffers方法的具体用法?C++ VkLayerDispatchTable::CmdBindVertexBuffers怎么用?C++ VkLayerDispatchTable::CmdBindVertexBuffers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VkLayerDispatchTable
的用法示例。
在下文中一共展示了VkLayerDispatchTable::CmdBindVertexBuffers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: before_present
static void before_present(VkQueue queue, layer_data *my_data, SwapChainData *swapChain, unsigned imageIndex) {
VkLayerDispatchTable *pTable = my_data->device_dispatch_table;
if (!my_data->fontUploadComplete) {
VkSubmitInfo si = {};
si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
si.pNext = nullptr;
si.waitSemaphoreCount = 0;
si.commandBufferCount = 1;
si.signalSemaphoreCount = 0;
si.pCommandBuffers = &my_data->fontUploadCmdBuffer;
pTable->QueueSubmit(queue, 1, &si, VK_NULL_HANDLE);
my_data->fontUploadComplete = true;
#ifdef OVERLAY_DEBUG
printf("Font image layout transition queued\n");
#endif
}
WsiImageData *id = swapChain->presentableImages[imageIndex];
/* update the overlay content */
vertex *vertices = nullptr;
/* guaranteed not in flight due to WSI surface being available */
VkResult U_ASSERT_ONLY err =
pTable->MapMemory(my_data->dev, id->vertexBufferMemory, 0, id->vertexBufferSize, 0, (void **)&vertices);
assert(!err);
/* write vertices for string in here */
id->numVertices = fill_vertex_buffer(my_data, vertices, imageIndex);
pTable->UnmapMemory(my_data->dev, id->vertexBufferMemory);
/* JIT record a command buffer to draw the overlay */
VkCommandBufferBeginInfo cbbi;
cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cbbi.pNext = nullptr;
cbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
cbbi.pInheritanceInfo = nullptr;
VkImageMemoryBarrier imb;
imb.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
imb.pNext = nullptr;
imb.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
imb.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
imb.oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
imb.newLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
imb.image = id->image;
imb.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
imb.subresourceRange.baseMipLevel = 0;
imb.subresourceRange.levelCount = 1;
imb.subresourceRange.baseArrayLayer = 0;
imb.subresourceRange.layerCount = 1;
imb.srcQueueFamilyIndex = my_data->graphicsQueueFamilyIndex;
imb.dstQueueFamilyIndex = my_data->graphicsQueueFamilyIndex;
VkRenderPassBeginInfo rpbi;
rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rpbi.pNext = nullptr;
rpbi.renderPass = swapChain->render_pass;
rpbi.framebuffer = id->framebuffer;
rpbi.renderArea.offset.x = 0;
rpbi.renderArea.offset.y = 0;
rpbi.renderArea.extent.width = swapChain->width;
rpbi.renderArea.extent.height = swapChain->height;
rpbi.clearValueCount = 0;
rpbi.pClearValues = nullptr;
pTable->BeginCommandBuffer(id->cmd, &cbbi);
pTable->CmdPipelineBarrier(id->cmd, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT,
0 /* dependency flags */, 0, nullptr, /* memory barriers */
0, nullptr, /* buffer memory barriers */
1, &imb); /* image memory barriers */
pTable->CmdBeginRenderPass(id->cmd, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
pTable->CmdBindPipeline(id->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, swapChain->pipeline);
pTable->CmdBindDescriptorSets(id->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, my_data->pl, 0, 1, &my_data->desc_set, 0, nullptr);
VkDeviceSize offsets[] = {0};
VkBuffer buffers[] = {id->vertexBuffer};
pTable->CmdBindVertexBuffers(id->cmd, 0, 1, buffers, offsets);
pTable->CmdDraw(id->cmd, id->numVertices, 1, 0, 0);
pTable->CmdEndRenderPass(id->cmd);
pTable->EndCommandBuffer(id->cmd);
/* Schedule this command buffer for execution. TODO: Do we need to protect
* ourselves from an app that didn't wait for the presentation image to
* be idle before mangling it? If the app is well-behaved, our command
* buffer is guaranteed to have been retired before the app tries to
* present it again.
*/
VkSubmitInfo si = {};
si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
si.pNext = nullptr;
//.........这里部分代码省略.........
示例2: before_present
static void before_present(VkQueue queue, layer_data *my_data,
SwapChainData *swapChain, unsigned imageIndex) {
VkLayerDispatchTable *pTable = my_data->device_dispatch_table;
if (!my_data->fontUploadComplete) {
VkSubmitInfo si;
si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
si.pNext = nullptr;
si.waitSemaphoreCount = 0;
si.commandBufferCount = 1;
si.signalSemaphoreCount = 0;
si.pCommandBuffers = &my_data->fontUploadCmdBuffer;
pTable->QueueSubmit(queue, 1, &si, VK_NULL_HANDLE);
my_data->fontUploadComplete = true;
#ifdef OVERLAY_DEBUG
printf("Font image layout transition queued\n");
#endif
}
WsiImageData *id = swapChain->presentableImages[imageIndex];
/* update the overlay content */
vertex *vertices = nullptr;
/* guaranteed not in flight due to WSI surface being available */
VkResult U_ASSERT_ONLY err =
pTable->MapMemory(my_data->dev, id->vertexBufferMemory, 0,
id->vertexBufferSize, 0, (void **)&vertices);
assert(!err);
/* write vertices for string in here */
id->numVertices = fill_vertex_buffer(my_data, vertices, imageIndex);
pTable->UnmapMemory(my_data->dev, id->vertexBufferMemory);
/* JIT record a command buffer to draw the overlay */
VkCommandBufferBeginInfo cbbi;
cbbi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cbbi.pNext = nullptr;
cbbi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
cbbi.pInheritanceInfo = nullptr;
VkRenderPassBeginInfo rpbi;
rpbi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
rpbi.pNext = nullptr;
rpbi.renderPass = swapChain->render_pass;
rpbi.framebuffer = id->framebuffer;
rpbi.renderArea.offset.x = 0;
rpbi.renderArea.offset.y = 0;
rpbi.renderArea.extent.width = swapChain->width;
rpbi.renderArea.extent.height = swapChain->height;
rpbi.clearValueCount = 0;
rpbi.pClearValues = nullptr;
pTable->BeginCommandBuffer(id->cmd, &cbbi);
pTable->CmdBeginRenderPass(id->cmd, &rpbi, VK_SUBPASS_CONTENTS_INLINE);
pTable->CmdBindPipeline(id->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
swapChain->pipeline);
pTable->CmdBindDescriptorSets(id->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS,
my_data->pl, 0, 1, &my_data->desc_set, 0,
nullptr);
VkDeviceSize offsets[] = {0};
VkBuffer buffers[] = {id->vertexBuffer};
pTable->CmdBindVertexBuffers(id->cmd, 0, 1, buffers, offsets);
pTable->CmdDraw(id->cmd, id->numVertices, 1, 0, 0);
pTable->CmdEndRenderPass(id->cmd);
pTable->EndCommandBuffer(id->cmd);
/* Schedule this command buffer for execution. TODO: Do we need to protect
* ourselves from an app that didn't wait for the presentation image to
* be idle before mangling it? If the app is well-behaved, our command
* buffer is guaranteed to have been retired before the app tries to
* present it again.
*/
VkFence null_fence = VK_NULL_HANDLE;
VkSubmitInfo si;
si.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
si.pNext = nullptr;
si.waitSemaphoreCount = 0;
si.commandBufferCount = 1;
si.signalSemaphoreCount = 0;
si.pCommandBuffers = &id->cmd;
pTable->QueueSubmit(queue, 1, &si, null_fence);
/* Reset per-frame stats */
my_data->cmdBuffersThisFrame = 0;
}