当前位置: 首页>>代码示例>>C++>>正文


C++ VkLayerDispatchTable::CmdEndRenderPass方法代码示例

本文整理汇总了C++中VkLayerDispatchTable::CmdEndRenderPass方法的典型用法代码示例。如果您正苦于以下问题:C++ VkLayerDispatchTable::CmdEndRenderPass方法的具体用法?C++ VkLayerDispatchTable::CmdEndRenderPass怎么用?C++ VkLayerDispatchTable::CmdEndRenderPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VkLayerDispatchTable的用法示例。


在下文中一共展示了VkLayerDispatchTable::CmdEndRenderPass方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;

    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;
}
开发者ID:10imaging,项目名称:vulkan-basic-samples,代码行数:95,代码来源:overlay.cpp


注:本文中的VkLayerDispatchTable::CmdEndRenderPass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。